📄 cspeclayer.java
字号:
// Static Args can't go out null.... String staticArguments = getStaticArgs(); if (staticArguments == null) { staticArguments = ""; setStaticArgs(staticArguments); } // neither can dynamic args // Layer.getArgs() was deprecated and removed dynamicArgsHolder = new StringHolder(getArgs()); if (dynamicArgsHolder.value == null) { dynamicArgsHolder.value = ""; } // call getRectangle(); if (Debug.debugging("cspec")) { Debug.output(getName() + "|CSpecLayer.getSpecGraphics():" + " calling getRectangle with projection: " + p + " ul=" + ul + " lr=" + lr + " staticArgs=\"" + staticArguments + "\"" + " dynamicArgs=\"" + dynamicArgsHolder.value + "\"" + " notifyOnChange=\"" + notifyOnChange + "\"" + " clientID=" + clientID); } long start = System.currentTimeMillis(); if (Debug.debugging("cspecdetail")) { Debug.output("*** Specialist Server: is a " + spec.getClass().getName() + "\n" + spec); } graphics = spec.getRectangle(cproj, ll1, ll2, staticArguments, dynamicArgsHolder, selectDist, wantAreaEvents, notifyOnChange, clientID); long stop = System.currentTimeMillis(); if (Debug.debugging("cspec")) { Debug.output(getName() + "|CSpecLayer.getSpecGraphics(): got " + graphics.length + " graphics in " + ((stop - start) / 1000d) + " seconds."); } } catch (org.omg.CORBA.SystemException e) { dirtybits |= EXCEPTION; // don't freak out if we were only interrupted... if (e.toString().indexOf("InterruptedIOException") != -1) { System.err.println(getName() + "|CSpecLayer.getSpecGraphics(): " + "getRectangle() call interrupted!"); } else { System.err.println(getName() + "|CSpecLayer.getSpecGraphics(): " + "Caught CORBA exception: " + e); System.err.println(getName() + "|CSpecLayer.getSpecGraphics(): " + "Exception class: " + e.getClass().getName()); e.printStackTrace(); } // dontcha just love CORBA? reinit later setSpecialist(null); if (showDialogs) postCORBAErrorMsg("CORBA Exception while getting graphics from\n" + getName() + " specialist:\n" + e.getClass().getName()); } return graphics; } /** * Prepares the graphics for the layer. * <p> * Occasionally it is necessary to abort a prepare call. When this * happens, the doPrepare() call will set the cancel bit on the * SwingWorker. The worker will get restarted after it finishes * doing its cleanup. * * @return a JGraphicList from the server. */ public synchronized OMGraphicList prepare() { JGraphicList emptyList = new JGraphicList(); if (isCancelled()) { dirtybits |= PREMATURE_FINISH; if (Debug.debugging("basic")) { Debug.output(getName() + "|CSpecLayer.prepare(): aborted."); } return emptyList; } if (Debug.debugging("basic")) { Debug.output(getName() + "|CSpecLayer.prepare(): doing it"); } dirtybits = 0;//reset the dirty bits // Now we're going to shut off event processing. The only // thing that turns them on again is finishing successfully. setAcceptingEvents(false); Projection projection = getProjection(); // get the graphics from the specialist UGraphic[] specGraphics = getSpecGraphics(projection); if (isCancelled()) { dirtybits |= PREMATURE_FINISH; if (Debug.debugging("basic")) Debug.output(getName() + "|CSpecLayer.prepare(): " + "aborted during/after getRectangle()."); return emptyList; } if (specGraphics == null) { return emptyList; } // process the graphics long start = System.currentTimeMillis(); JGraphicList graphics = createGraphicsList(specGraphics, projection); long stop = System.currentTimeMillis(); if (Debug.debugging("cspec")) { Debug.output(getName() + "|CSpecLayer.prepare(): generated " + specGraphics.length + " graphics in " + ((stop - start) / 1000d) + " seconds."); } if (isCancelled()) { dirtybits |= PREMATURE_FINISH; if (Debug.debugging("basic")) { Debug.output(getName() + "|CSpecLayer.prepare(): " + "aborted while generating graphics."); } return emptyList; } // safe quit if (Debug.debugging("basic")) { Debug.output(getName() + "|CSpecLayer.prepare(): finished preparing " + graphics.size() + " graphics"); } setAcceptingEvents(true); return graphics; } /** * Create an JGraphicList based on UGraphics and a Projection. * <p> * This is public static to enable out-of-package delegation. * <p> * * @param uGraphics UGraphic[] * @param proj Projection * @return JGraphicList */ public static JGraphicList createGraphicsList(UGraphic[] uGraphics, Projection proj) { int nGraphics = uGraphics.length; JGraphicList graphics = new JGraphicList(nGraphics); graphics.setTraverseMode(OMGraphicList.LAST_ADDED_ON_TOP); // generate a JGraphic for each CSpecialist graphic and store // it for (int i = 0; i < nGraphics; i++) { switch (uGraphics[i].discriminator().value()) { case GraphicType._GT_Poly: JPoly jpoly = new JPoly(uGraphics[i].epoly()); jpoly.generate(proj); graphics.addOMGraphic(jpoly); break; case GraphicType._GT_Raster: JRaster jraster = new JRaster(uGraphics[i].eras()); jraster.generate(proj); graphics.addOMGraphic(jraster); break; case GraphicType._GT_Bitmap: JBitmap jbitmap = new JBitmap(uGraphics[i].ebit()); jbitmap.generate(proj); graphics.addOMGraphic(jbitmap); break; case GraphicType._GT_Text: JText jtext = new JText(uGraphics[i].etext()); jtext.generate(proj); graphics.addOMGraphic(jtext); break; case GraphicType._GT_Line: JLine jline = new JLine(uGraphics[i].eline()); jline.generate(proj); graphics.addOMGraphic(jline); break; case GraphicType._GT_UnitSymbol: JUnit junit = new JUnit(uGraphics[i].eunit()); junit.generate(proj); graphics.addOMGraphic(junit); break; case GraphicType._GT_2525Symbol: J2525 j2525 = new J2525(uGraphics[i].e2525()); j2525.generate(proj); graphics.addOMGraphic(j2525); break; case GraphicType._GT_Rectangle: JRect jrect = new JRect(uGraphics[i].erect()); jrect.generate(proj); graphics.addOMGraphic(jrect); break; case GraphicType._GT_Circle: JCircle jcircle = new JCircle(uGraphics[i].ecirc()); jcircle.generate(proj); graphics.addOMGraphic(jcircle); break; case GraphicType._GT_NewGraphic: case GraphicType._GT_ReorderGraphic: default: System.err.println("JGraphic.generateGraphics: " + "ignoring invalid type"); break; } } return graphics; } /** * Gets the palette associated with the layer. * <p> * * @return Component or null */ public Component getGUI() { if (specialist == null) initSpecialist(); if (specialist == null) { if (Debug.debugging("cspec")) Debug.output(getName() + "|CSpecLayer.getGUI(): initSpecialist() unsuccessful!"); return null; } try { if (widgets == null) { org.omg.CORBA.StringHolder paletteDynamicArgs = new org.omg.CORBA.StringHolder(getArgs()); if (paletteDynamicArgs.value == null) { paletteDynamicArgs.value = ""; } // Static Args can't go out null.... String staticArguments = getStaticArgs(); if (staticArguments == null) { staticArguments = ""; setStaticArgs(staticArguments); } if (Debug.debugging("cspec")) { Debug.output(getName() + "|CSpecLayer.getGUI(): calling getPaletteConfig(" + staticArguments + "," + paletteDynamicArgs.value + "," + clientID + ")"); } try { widgets = specialist.getPaletteConfig(null/* widgetChange */, staticArguments, paletteDynamicArgs, clientID); } catch (org.omg.CORBA.SystemException e) { System.err.println(getName() + "|CSpecLayer.getGUI(): " + e); e.printStackTrace(); setSpecialist(null); if (showDialogs) { postCORBAErrorMsg("CORBA Exception while getting palette from\n" + getName() + " specialist:\n" + e.getClass().getName()); } } if (widgets == null || widgets.length == 0) { gui = null; } else { gui = new CSpecPalette(widgets, clientID, this); } } } catch (OutOfMemoryError e) { setSpecialist(null); System.err.println(getName() + "|CSpecLayer.getGUI(): " + e); if (showDialogs) { postMemoryErrorMsg("OutOfMemory while getting palette from\n" + getName() + " specialist."); } } catch (Throwable t) { setSpecialist(null); System.err.println(getName() + "|CSpecLayer.getGUI(): " + t); t.printStackTrace(); if (showDialogs) { postException("Exception while getting palette from\n" + getName() + " specialist:\n" + t.getClass().getName()); } } return gui; } /** * A palette button has changed (we should indeed prepare when we * get the call). * * @param paletteIsDirty true or false */ protected void setPaletteIsDirty(boolean paletteIsDirty) { if (paletteIsDirty) { dirtybits |= PALETTE_DIRTY; } } /** * Destroy the current palette stuff. */ protected void forgetPalette() { widgets = null; gui = null; } /** * Used to set whether the MapMouseListener is listening for * events or ignoring them. * * @param listening true if the listener should process mouse * events. */ public void setAcceptingEvents(boolean listening) { acceptingEvents = listening; } /** * Used to tell if the listener is accepting mouse events for * processing. * * @return true if the listener is processing mouse events. */ public boolean isAcceptingEvents() { return acceptingEvents; } // Mouse Listener events //////////////////////// /** * Returns the MapMouseListener object (this object) that handles * the mouse events. * * @return MapMouseListener this */ public MapMouseListener getMapMouseListener() { return this; } public String[] getMouseModeServiceList() { String[] ret = new String[1]; ret[0] = SelectMouseMode.modeID; return ret; } /** * Handle a mouse button being pressed. * * @param e MouseListener MouseEvent to handle. * @return true if the listener was able to process the event. */ public boolean mousePressed(MouseEvent e) { if (acceptingEvents && specialist != null) { return handleGesture(e, MapGesture.clickEvent, true); } return false; } /** * Handle a mouse button being released. * * @param e MouseListener MouseEvent to handle. * @return true if the listener was able to process the event. */ public boolean mouseReleased(MouseEvent e) { if (acceptingEvents && specialist != null) { return handleGesture(e, MapGesture.clickEvent, false); } return false; } /** * Handle a mouse button being clicked - pressed and released. * * @param e MouseListener MouseEvent to handle. * @return true if the listener was able to process the event. */ public boolean mouseClicked(MouseEvent e) { if (acceptingEvents && specialist != null) { return handleGesture(e, MapGesture.clickEvent, false); } return false; } /** * Handle a mouse cursor entering a window or area. * * @param e MouseListener MouseEvent to handle. */ public void mouseEntered(MouseEvent e) { if (acceptingEvents && specialist != null) { handleGesture(e, MapGesture.motionEvent, false); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -