?? j2525.java
字號:
// **********************************************************************// // <copyright>// // BBN Technologies// 10 Moulton Street// Cambridge, MA 02138// (617) 873-8000// // Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source:// /cvs/distapps/openmap/src/corba/com/bbn/openmap/layer/specialist/J2525.java,v// $// $RCSfile: J2525.java,v $// $Revision: 1.2.2.1 $// $Date: 2004/10/14 18:26:30 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.specialist;import com.bbn.openmap.CSpecialist.U2525SymbolPackage.E2525Symbol;import com.bbn.openmap.omGraphics.*;import com.bbn.openmap.proj.Projection;import java.awt.Graphics;import java.awt.Point;import java.awt.image.ImageObserver;import javax.swing.ImageIcon;public class J2525 extends OMGraphic implements JObjectHolder { protected transient com.bbn.openmap.CSpecialist.EComp object = null; E2525Symbol e2525 = null; Point point1; ImageIcon bitmap; ImageObserver observer; public J2525(E2525Symbol e2525) { super(); JGraphic.fillOMGraphicParams(this, e2525.egraphic); } public void setObject(com.bbn.openmap.CSpecialist.EComp aObject) { object = aObject; } public com.bbn.openmap.CSpecialist.EComp getObject() { return object; } /** generate() - prepares the graphics for rendering. */ public boolean generate(Projection proj) { setNeedToRegenerate(false); switch (renderType) { case RENDERTYPE_XY: break; case RENDERTYPE_OFFSET: break; case RENDERTYPE_LATLON: point1 = proj.forward(e2525.ll1.lat, e2525.ll1.lon); // I'm cheating and forcing all 2525 symbols to be // represented by a // single bitmap. Ideally, we'd use a ported version of // the GSD // library to generate an appropriate bitmap for us. bitmap = new ImageIcon("plus.bm"); break; case RENDERTYPE_UNKNOWN: System.err.println("J2525.generate: invalid RenderType"); return false; } return true; } /** render() - renders the 2525 symbol. */ public void render(Graphics g) { if (g == null) { System.err.println("J2525.render: can't render null Graphics"); return; } g.setColor(getDisplayColor()); if (bitmap != null) { System.out.println("\n\nHelp!!!!: J2525 can't draw an image!"); // Need to update this to JFC, but need an // ImageObserver... //g.drawImage(bitmap, point1.x, point1.y); } else { System.err.println("J2525.render: ignoring null bitmap"); } // I'm cheating and drawing in the most-used annotation // (bottom1), // and ignoring all the others. // Determine proper positioning of the bottom1 label. // netscape.application.Font f = // netscape.application.Font.defaultFont(); // netscape.application.FontMetrics fm = f.fontMetrics(); // netscape.application.Size sz = // fm.stringSize(e2525.bottom1); // int x,y; // x = point1.x + (bitmap.width() / 2); // y = point1.y + bitmap.height(); // x -= sz.width/2; // y += sz.height; // g.setFont(f); // g.drawString(e2525.bottom1, x, y); int x = point1.x + (bitmap.getImage().getWidth(observer) / 2); int y = point1.y + bitmap.getImage().getHeight(observer); int w = g.getFontMetrics().stringWidth(e2525.bottom1); int h = g.getFontMetrics().getHeight(); x -= w / 2; y += h; g.drawString(e2525.bottom1, x, y); } /** * distance() - returns the shortest distance from the 2525 symbol * to an XY-point */ public float distance(int x, int y) { float distance = Float.POSITIVE_INFINITY; return distance; } public void update( com.bbn.openmap.CSpecialist.GraphicPackage.GF_update update) { JGraphic.update((JObjectHolder) this, update); }} // class J2525
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -