public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); if (cmd.equals("del")) { try { UnionSet set = (UnionSet) ref.getData(); SampledSet[] sets = set.getSets(); SampledSet[] new_sets = new SampledSet[sets.length - 1]; System.arraycopy(sets, 0, new_sets, 0, sets.length - 1); ref.setData(new UnionSet(set.getType(), new_sets)); } catch (VisADException ex) { } catch (RemoteException ex) { } } else if (cmd.equals("fill")) { UnionSet set = null; try { set = (UnionSet) ref.getData(); System.out.println("area = " + DelaunayCustom.computeArea(set)); } catch (VisADException ex) { System.out.println(ex.getMessage()); } try { // Irregular2DSet new_set = DelaunayCustom.fill(set); Irregular2DSet new_set = DelaunayCustom.fillCheck(set, false); if (new_ref == null) { new_ref = new DataReferenceImpl("fill"); ConstantMap[] cmaps = new ConstantMap[] { new ConstantMap(1.0, Display.Blue), new ConstantMap(1.0, Display.Red), new ConstantMap(0.0, Display.Green) }; DataRenderer renderer = (display instanceof DisplayImplJ3D) ? (DataRenderer) new DefaultRendererJ3D() : (DataRenderer) new DefaultRendererJ2D(); renderer.suppressExceptions(true); display.addReferences(renderer, new_ref, cmaps); } new_ref.setData(new_set); } catch (VisADException ex) { System.out.println(ex.getMessage()); } catch (RemoteException ex) { System.out.println(ex.getMessage()); } } else if (cmd.equals("lines")) { try { lines = !lines; GraphicsModeControl mode = display.getGraphicsModeControl(); if (lines) { mode.setPolygonMode(DisplayImplJ3D.POLYGON_LINE); } else { mode.setPolygonMode(DisplayImplJ3D.POLYGON_FILL); } } catch (VisADException ex) { System.out.println(ex.getMessage()); } catch (RemoteException ex) { System.out.println(ex.getMessage()); } } }
/** * prepare for transforming Data into scene graph depictions, including possible auto-scaling of * ScalarMaps * * @param temp Vector of DataRenderers * @param tmap Vector of ScalarMaps * @param go flag indicating whether Data transforms are requested * @param initialize flag indicating whether auto-scaling is requested * @throws VisADException a VisAD error occurred * @throws RemoteException an RMI error occurred */ public void prepareAction(Vector temp, Vector tmap, boolean go, boolean initialize) throws VisADException, RemoteException { DataShadow shadow = null; Enumeration renderers = temp.elements(); while (renderers.hasMoreElements()) { DataRenderer renderer = (DataRenderer) renderers.nextElement(); shadow = renderer.prepareAction(go, initialize, shadow); } if (shadow != null) { // apply RealType ranges and animationSampling Enumeration maps = tmap.elements(); while (maps.hasMoreElements()) { ScalarMap map = ((ScalarMap) maps.nextElement()); map.setRange(shadow); } } ScalarMap.equalizeFlow(tmap, Display.DisplayFlow1Tuple); ScalarMap.equalizeFlow(tmap, Display.DisplayFlow2Tuple); }
/** * Indicates if this instance is identical to another object. * * @param obj The other object. * @return <code>true</code> if and only if this instance is identical to the other object. */ public boolean equals(Object obj) { boolean equals; if (!(obj instanceof DisplayableMeanWind)) { equals = false; } else { DisplayableMeanWind that = (DisplayableMeanWind) obj; equals = (this == that) || ((dataRenderer == null) ? that.dataRenderer == null : dataRenderer.equals(that.dataRenderer)) && super.equals(that); } return equals; }
/** * Returns the hash code of this instance. * * @return The hash code of this instance. */ public int hashCode() { return ((dataRenderer == null) ? 0 : dataRenderer.hashCode()) ^ super.hashCode(); }
/** * Method description * * @param track * @param context * @param arect */ @Override public void renderAxis(Track track, RenderContext context, Rectangle arect) { // For now disable axes for all chromosome view if (context.getChr().equals(Globals.CHR_ALL)) { return; } super.renderAxis(track, context, arect); Rectangle drawingRect = calculateDrawingRect(arect); PreferenceManager prefs = PreferenceManager.getInstance(); Color labelColor = prefs.getAsBoolean(PreferenceManager.CHART_COLOR_TRACK_NAME) ? track.getColor() : Color.black; Graphics2D labelGraphics = context.getGraphic2DForColor(labelColor); labelGraphics.setFont(FontManager.getFont(8)); if (prefs.getAsBoolean(PreferenceManager.CHART_DRAW_TRACK_NAME)) { // Only attempt if track height is > 25 pixels if (arect.getHeight() > 25) { Rectangle labelRect = new Rectangle(arect.x, arect.y + 10, arect.width, 10); labelGraphics.setFont(FontManager.getFont(10)); GraphicUtils.drawCenteredText(track.getName(), labelRect, labelGraphics); } } if (prefs.getAsBoolean(PreferenceManager.CHART_DRAW_Y_AXIS)) { Rectangle axisRect = new Rectangle(arect.x, arect.y + 1, AXIS_AREA_WIDTH, arect.height); DataRange axisDefinition = track.getDataRange(); float maxValue = axisDefinition.getMaximum(); float baseValue = axisDefinition.getBaseline(); float minValue = axisDefinition.getMinimum(); // Bottom (minimum tick mark) int pY = computeYPixelValue(drawingRect, axisDefinition, minValue); labelGraphics.drawLine( axisRect.x + AXIS_AREA_WIDTH - 10, pY, axisRect.x + AXIS_AREA_WIDTH - 5, pY); GraphicUtils.drawRightJustifiedText( formatter.format(minValue), axisRect.x + AXIS_AREA_WIDTH - 15, pY, labelGraphics); // Top (maximum tick mark) int topPY = computeYPixelValue(drawingRect, axisDefinition, maxValue); labelGraphics.drawLine( axisRect.x + AXIS_AREA_WIDTH - 10, topPY, axisRect.x + AXIS_AREA_WIDTH - 5, topPY); GraphicUtils.drawRightJustifiedText( formatter.format(maxValue), axisRect.x + AXIS_AREA_WIDTH - 15, topPY + 4, labelGraphics); // Connect top and bottom labelGraphics.drawLine( axisRect.x + AXIS_AREA_WIDTH - 10, topPY, axisRect.x + AXIS_AREA_WIDTH - 10, pY); // Middle tick mark. Draw only if room int midPY = computeYPixelValue(drawingRect, axisDefinition, baseValue); if ((midPY < pY - 15) && (midPY > topPY + 15)) { labelGraphics.drawLine( axisRect.x + AXIS_AREA_WIDTH - 10, midPY, axisRect.x + AXIS_AREA_WIDTH - 5, midPY); GraphicUtils.drawRightJustifiedText( formatter.format(baseValue), axisRect.x + AXIS_AREA_WIDTH - 15, midPY + 4, labelGraphics); } } else if (track.isShowDataRange() && arect.height > 20) { drawScale(track.getDataRange(), context, arect); } }