📄 graphicwarehousesupport.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/vpf/GraphicWarehouseSupport.java,v// $// $RCSfile: GraphicWarehouseSupport.java,v $// $Revision: 1.3.2.3 $// $Date: 2005/08/11 21:03:32 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.layer.specialist.vpf;import java.awt.Component;import java.lang.Math;import java.util.ArrayList;import java.util.List;import java.util.Vector;import com.bbn.openmap.layer.vpf.LibrarySelectionTable;import com.bbn.openmap.layer.vpf.VPFGraphicWarehouse;import com.bbn.openmap.layer.vpf.CoordFloatString;import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.CSpecialist.Comp;import com.bbn.openmap.CSpecialist.GraphicPackage.LineType;import com.bbn.openmap.CSpecialist.GraphicPackage.RenderType;import com.bbn.openmap.CSpecialist.LLPoint;import com.bbn.openmap.CSpecialist.UGraphic;import com.bbn.openmap.layer.specialist.GraphicList;import com.bbn.openmap.layer.specialist.SColor;import com.bbn.openmap.layer.specialist.SPoly;import com.bbn.openmap.layer.specialist.SText;public abstract class GraphicWarehouseSupport implements VPFGraphicWarehouse { /** HACK around antarctica display problem. */ final transient protected static float antarcticaThreshold = -89.9f; /** hang on to the graphics that we build */ protected GraphicList graphics; /** remember if we draw edge features */ private boolean drawEdgeFeatures; /** remember if we draw text features */ private boolean drawTextFeatures; /** remember if we draw area features */ private boolean drawAreaFeatures; /** remember if we draw point features */ private boolean drawPointFeatures; /** * */ public GraphicWarehouseSupport() { graphics = new GraphicList(); } /** * Lets the warehouse know that a different CoverageAttributeTable * will be using it. Default action is to do nothing. */ public void resetForCAT() {} /** * Return the GUI for certain warehouse attributes. By default, * return the GUI for the DrawingAttributes object being used for * rendering attributes of the graphics. * * @param lst LibrarySelectionTable to use to get information * about the data, if needed. Not needed here. */ public Component getGUI(LibrarySelectionTable lst) { return null; } /** * set if we draw edge features * * @param newvalue <code>true</code> for drawing, false * otherwise */ public void setEdgeFeatures(boolean newvalue) { drawEdgeFeatures = newvalue; } /** * Return true if we may draw some edge features. */ public boolean drawEdgeFeatures() { return drawEdgeFeatures; } /** * set if we draw text features * * @param newvalue <code>true</code> for drawing, false * otherwise */ public void setTextFeatures(boolean newvalue) { drawTextFeatures = newvalue; } /** * Return true if we may draw some text features. */ public boolean drawTextFeatures() { return drawTextFeatures; } /** * set if we draw area features * * @param newvalue <code>true</code> for drawing, false * otherwise */ public void setAreaFeatures(boolean newvalue) { com.bbn.openmap.util.Debug.message("vpfspecialist", "Setting area features to " + newvalue); drawAreaFeatures = newvalue; } /** * Return true if we may draw some area features. */ public boolean drawAreaFeatures() { return drawAreaFeatures; } /** * set if we draw point features * * @param newvalue <code>true</code> for drawing, false * otherwise */ public void setPointFeatures(boolean newvalue) { drawPointFeatures = newvalue; } /** * Return true if we may draw some point features. */ public boolean drawPointFeatures() { return drawPointFeatures; } /** * */ protected SPoly createAreaSPoly(List jpts, int totalSize, LatLonPoint ll1, LatLonPoint ll2, float dpplat, float dpplon) { int size = jpts.size(); List ipts = new ArrayList(size * 2); // HACK maybe should fold this loop into the loop inside // generatePolyPts() for (int j = 0; j < size; j++) { CoordFloatString cfs = (CoordFloatString) jpts.get(j); int cfscnt = cfs.tcount; int cfssz = cfs.tsize; float cfsvals[] = cfs.vals; if (cfscnt > 0) { // normal for (int i = 0; i < cfscnt; i++) { ipts.add(new LLPoint(cfsvals[i * cfssz + 1], cfsvals[i * cfssz])); } } else { // reverse cfscnt *= -1; // normalize for (int i = cfscnt - 1; i >= 0; i--) { ipts.add(new LLPoint(cfsvals[i * cfssz + 1], cfsvals[i * cfssz])); } } } LLPoint pts[] = generatePolyPts(ipts, ll1.getLatitude(), ll2.getLatitude(), ll2.getLongitude(), ll1.getLongitude(), dpplat, dpplon); if (pts == null) { //Debug.message("dcwSpecialist.clipping", // "Completely eliminated poly"); return null; } SPoly py = new SPoly(pts, LineType.LT_Straight); return py; } /** * */ public LLPoint[] generatePolyPts(List ipts, float north, float south, float east, float west, float dpplat, float dpplon) { int coordcount = ipts.size(); /* * Let me explain. We might be inserting some extra points to * work around a problem displaying Antarctica in cylindrical * projections. So the initial capacity of the Vector is set * to the number of points. The increment value is set to 5 * since that's how many points we'll add if we hit the * antarctica thing. That way we're not allocating a huge new * Vector when we don't really need to. */ Vector vPts = new Vector(coordcount, 5); // HACK: we will rewrite the data for the Antarctica polygon // so that // it will display "correctly" in the cylindrical projections. //only check if bottom edge of screen below a certain // latitude boolean weaseledOurWayAroundAntarcticAnomaly = (south >= -62f); LLPoint prevPt = null; for (int i = 0; i < coordcount; i++) { LLPoint pt = (LLPoint) ipts.get(i); float lllat = pt.lat; if ((prevPt != null) && (i != (coordcount - 1)) && (Math.abs(prevPt.lat - pt.lat) < dpplat) && (Math.abs(prevPt.lon - pt.lon) < dpplon)) { continue; } vPts.add(pt); prevPt = pt; if (!weaseledOurWayAroundAntarcticAnomaly && (lllat < antarcticaThreshold)) { weaseledOurWayAroundAntarcticAnomaly = true; System.out.println("AreaTable.generateSPoly(): Antarctica!"); //another HACK: we're assuming data is going from // west to east, //so we wrap the other way vPts.add(new LLPoint(-89.99f, 179.99f)); vPts.add(new LLPoint(-89.99f, 90f)); vPts.add(new LLPoint(-89.99f, 0f)); vPts.add(new LLPoint(-89.99f, -90f)); vPts.add(new LLPoint(-89.99f, -179.99f)); prevPt = (LLPoint) vPts.lastElement(); //advance to western hemisphere where we //pick up the real data again while (((LLPoint) ipts.get(i)).lon > 0) { ++i; } } } int nPts = vPts.size(); if (nPts == 0) { return null; } else { LLPoint pts[] = new LLPoint[nPts]; vPts.copyInto(pts); return pts; } } SColor edgeColors[] = { new SColor((short) 65535, (short) 0, (short) 0), // red new SColor((short) 0, (short) 65535, (short) 0), // green new SColor((short) 0, (short) 0, (short) 65535), // blue new SColor((short) 32768, (short) 32768, (short) 32768), // grey50 new SColor((short) 65535, (short) 65535, (short) 65535) // black }; /** * */ public SPoly createEdgeSPoly(CoordFloatString coords, LatLonPoint ll1, LatLonPoint ll2, float dpplat, float dpplon) { // System.out.print("."); // System.out.flush(); LLPoint pts[] = clipToScreen(coords, ll1.getLatitude(), /* north */ ll2.getLatitude(), /* south */ ll2.getLongitude(), /* east */ ll1.getLongitude(), /* west */ dpplat, dpplon); // LLPoint pts[] = clipToScreen_tcm(coords, // ll1.getLatitude(), /* north */ // ll2.getLatitude(), /* south */ // ll2.getLongitude(), /* east */ // ll1.getLongitude(), /* west */ // dpplat, // dpplon); // int pts_len = (pts == null) ? -1 : pts.length; // int pts_tcm_len = (pts_tcm == null) ? -1 : pts_tcm.length; // if ( pts_len == pts_tcm_len ) { // } else { // System.out.println("Pts: "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -