boolean handleClickEvent(ClickEvent evt) { boolean evtHandled = false; if (state.isRadarVisible() && state.getLayer().xmlRadarAvailable) { if (evt.x > radarX && evt.x < radarX + radarObjects.getWidth() && evt.y > radarY && evt.y < radarY + radarObjects.getHeight()) { dialogState = RADAR_DIALOG; evtHandled = true; } } // Handle event if (state.getNextLayerStatus() == ARXState.READY) { // Loop through overlays Iterator<Overlay> overlayIt = state.getLayer().getOverlays().iterator(); while (!evtHandled && overlayIt.hasNext()) { Overlay ovl = overlayIt.next(); evtHandled = ovl.press(evt.x, evt.y, ctx, state); } // TODO:these should also be ordered according to distance. Iterator<Placemark> placemarkIt = state.getLayer().getZOrderedPlacemarks().iterator(); while (!evtHandled && placemarkIt.hasNext()) { Placemark pm = placemarkIt.next(); evtHandled = pm.press(evt.x, evt.y, ctx, state); } } return evtHandled; }
/* Wraps everything into a Cell Manager Class*/ private CellManager toCellManager(ImagePlus imp, ArrayList<PolygonRoi> rois, ImagePlus av_imp) { CellManager cm = new CellManager(av_imp, imp, this.ovr); Iterator itr = rois.iterator(); ArrayList<Double> av_sig = new ArrayList<>(); PolygonRoi roi; while (itr.hasNext()) { roi = (PolygonRoi) itr.next(); av_sig = Activity_Analysis.getAverageSignal(imp, roi); CalciumSignal ca_sig = new CalciumSignal(av_sig, this.dt_r); ovr.add(roi); ca_sig.DeltaF(); cm.addCell(ca_sig, roi); } // catch(Exception e){ // IJ.showMessage(e.getMessage()); // } // } ovr.setLabelColor(Color.WHITE); // ovr.setFillColor(Color.GREEN); ovr.setStrokeColor(Color.getHSBColor(100, 30, 87)); av_imp.setOverlay(ovr); av_imp.show(); IJ.run("In [+]", ""); IJ.run("In [+]", ""); return cm; }
// Added by Marcel Boeglin 2013.09.22 private Overlay projectHyperStackRois(Overlay overlay) { if (overlay == null) return null; int t1 = imp.getFrame(); int channels = projImage.getNChannels(); int slices = 1; int frames = projImage.getNFrames(); Overlay overlay2 = new Overlay(); Roi roi; int c, z, t; int size = channels * slices * frames; for (Roi r : overlay.toArray()) { c = r.getCPosition(); z = r.getZPosition(); t = r.getTPosition(); roi = (Roi) r.clone(); if (size == channels) { // current time frame if (z >= startSlice && z <= stopSlice && t == t1 || c == 0) { roi.setPosition(c); overlay2.add(roi); } } else if (size == frames * channels) { // all time frames if (z >= startSlice && z <= stopSlice) roi.setPosition(c, 1, t); else if (z == 0) roi.setPosition(c, 0, t); else continue; overlay2.add(roi); } } return overlay2; }
void drawOutline(ImageProcessor ip, Roi roi, int count) { if (showChoice == OVERLAY_OUTLINES || showChoice == OVERLAY_MASKS) { if (overlay == null) { overlay = new Overlay(); overlay.drawLabels(true); overlay.setLabelFont(new Font("SansSerif", Font.PLAIN, fontSize)); } Roi roi2 = (Roi) roi.clone(); roi2.setStrokeColor(Color.cyan); if (lineWidth != 1) roi2.setStrokeWidth(lineWidth); if (showChoice == OVERLAY_MASKS) roi2.setFillColor(Color.cyan); overlay.add(roi2); } else { Rectangle r = roi.getBounds(); int nPoints = ((PolygonRoi) roi).getNCoordinates(); int[] xp = ((PolygonRoi) roi).getXCoordinates(); int[] yp = ((PolygonRoi) roi).getYCoordinates(); int x = r.x, y = r.y; if (!inSituShow) ip.setValue(0.0); ip.moveTo(x + xp[0], y + yp[0]); for (int i = 1; i < nPoints; i++) ip.lineTo(x + xp[i], y + yp[i]); ip.lineTo(x + xp[0], y + yp[0]); if (showChoice != BARE_OUTLINES) { String s = ResultsTable.d2s(count, 0); ip.moveTo(r.x + r.width / 2 - ip.getStringWidth(s) / 2, r.y + r.height / 2 + fontSize / 2); if (!inSituShow) ip.setValue(1.0); ip.drawString(s); } } }
public static void setOverlay(Overlay s) { if (current != null) { current.dispose(); } last = current; current = s; current.create(); }
public boolean onDoubleTapEvent(final MotionEvent e, final MapView pMapView) { for (final Overlay overlay : this.overlaysReversed()) { if (overlay.onDoubleTapEvent(e, pMapView)) { return true; } } return false; }
public boolean onTrackballEvent(final MotionEvent event, final MapView pMapView) { for (final Overlay overlay : this.overlaysReversed()) { if (overlay.onTrackballEvent(event, pMapView)) { return true; } } return false; }
public boolean onKeyUp(final int keyCode, final KeyEvent event, final MapView pMapView) { for (final Overlay overlay : this.overlaysReversed()) { if (overlay.onKeyUp(keyCode, event, pMapView)) { return true; } } return false; }
public void onDetach(final MapView pMapView) { if (mTilesOverlay != null) { mTilesOverlay.onDetach(pMapView); } for (final Overlay overlay : this.overlaysReversed()) { overlay.onDetach(pMapView); } }
public boolean onSingleTapUp(final MotionEvent pEvent, final MapView pMapView) { for (final Overlay overlay : this.overlaysReversed()) { if (overlay.onSingleTapUp(pEvent, pMapView)) { return true; } } return false; }
public void redrawAll() { resetBackground(); // Reset the background to the original at the correct size.: for (Overlay overlay : overlays) { for (List<Annotation> annotations : overlay.getAnnotationSets()) { for (Annotation annotation : annotations) { annotation.drawOnCanvas(backingCanvas, resizeRatio); } } } }
/** @deprecated replaced by ImagePlus.setOverlay(ij.gui.Overlay) */ public void setDisplayList(Vector list) { if (list != null) { Overlay list2 = new Overlay(); list2.setVector(list); setOverlay(list2); } else setOverlay(null); if (overlay != null) overlay.drawLabels(overlay.size() > 0 && overlay.get(0).getStrokeColor() == null); else customRoi = false; repaint(); }
/** Return the ROI Manager "Show All" list as an overlay. */ public Overlay getShowAllList() { if (!showAllROIs) return null; if (showAllList != null) return showAllList; RoiManager rm = RoiManager.getInstance(); if (rm == null) return null; Roi[] rois = rm.getRoisAsArray(); if (rois.length == 0) return null; Overlay overlay = new Overlay(); for (int i = 0; i < rois.length; i++) overlay.add((Roi) rois[i].clone()); return overlay; }
/** @deprecated replaced by ImagePlus.setOverlay(Shape, Color, BasicStroke) */ public void setDisplayList(Shape shape, Color color, BasicStroke stroke) { if (shape == null) { setOverlay(null); return; } Roi roi = new ShapeRoi(shape); roi.setStrokeColor(color); roi.setStroke(stroke); Overlay list = new Overlay(); list.add(roi); setOverlay(list); }
public boolean onFling( final MotionEvent pEvent1, final MotionEvent pEvent2, final float pVelocityX, final float pVelocityY, final MapView pMapView) { for (final Overlay overlay : this.overlaysReversed()) { if (overlay.onFling(pEvent1, pEvent2, pVelocityX, pVelocityY, pMapView)) { return true; } } return false; }
public boolean onScroll( final MotionEvent pEvent1, final MotionEvent pEvent2, final float pDistanceX, final float pDistanceY, final MapView pMapView) { for (final Overlay overlay : this.overlaysReversed()) { if (overlay.onScroll(pEvent1, pEvent2, pDistanceX, pDistanceY, pMapView)) { return true; } } return false; }
void addSelection() { ImagePlus imp = IJ.getImage(); String macroOptions = Macro.getOptions(); if (macroOptions != null && IJ.macroRunning() && macroOptions.indexOf("remove") != -1) { imp.setOverlay(null); return; } Roi roi = imp.getRoi(); if (roi == null && imp.getOverlay() != null) { GenericDialog gd = new GenericDialog("No Selection"); gd.addMessage("\"Overlay>Add\" requires a selection."); gd.setInsets(15, 40, 0); gd.addCheckbox("Remove existing overlay", false); gd.showDialog(); if (gd.wasCanceled()) return; if (gd.getNextBoolean()) imp.setOverlay(null); return; } if (roi == null) { IJ.error("This command requires a selection."); return; } roi = (Roi) roi.clone(); if (roi.getStrokeColor() == null) roi.setStrokeColor(Toolbar.getForegroundColor()); int width = Line.getWidth(); Rectangle bounds = roi.getBounds(); boolean tooWide = width > Math.max(bounds.width, bounds.height) / 3.0; if (roi.getStroke() == null && width > 1 && !tooWide) roi.setStrokeWidth(Line.getWidth()); Overlay overlay = imp.getOverlay(); if (overlay != null && overlay.size() > 0 && !roi.isDrawingTool()) { Roi roi2 = overlay.get(overlay.size() - 1); if (roi.getStroke() == null) roi.setStrokeWidth(roi2.getStrokeWidth()); if (roi.getFillColor() == null) roi.setFillColor(roi2.getFillColor()); } boolean points = roi instanceof PointRoi && ((PolygonRoi) roi).getNCoordinates() > 1; if (points) roi.setStrokeColor(Color.red); if (!IJ.altKeyDown() && !(roi instanceof Arrow)) { RoiProperties rp = new RoiProperties("Add to Overlay", roi); if (!rp.showDialog()) return; } String name = roi.getName(); boolean newOverlay = name != null && name.equals("new-overlay"); if (overlay == null || newOverlay) overlay = new Overlay(); overlay.add(roi); imp.setOverlay(overlay); overlay2 = overlay; if (points || (roi instanceof ImageRoi) || (roi instanceof Arrow)) imp.killRoi(); Undo.setup(Undo.OVERLAY_ADDITION, imp); }
// Added by Marcel Boeglin 2013.09.23 private Overlay projectStackRois(Overlay overlay) { if (overlay == null) return null; Overlay overlay2 = new Overlay(); Roi roi; int s; for (Roi r : overlay.toArray()) { s = r.getPosition(); roi = (Roi) r.clone(); if (s >= startSlice && s <= stopSlice || s == 0) { roi.setPosition(s); overlay2.add(roi); } } return overlay2; }
@Obvious @Override public PhotoOverlay withOverlayObjectExtension( final List<AbstractObject> overlayObjectExtension) { super.withOverlayObjectExtension(overlayObjectExtension); return this; }
@Override protected void paintComponent(Graphics g) { BufferedImage image = theImage.getImage(); if (image != null) { Graphics2D gg = (Graphics2D) g.create(); overlay.paint(gg, image, theImage.getImageTransform()); gg.dispose(); } }
public void ctick(int dt) { int dt2 = dt + initdelay; initdelay = 0; for (GAttrib a : attr.values()) { if (a instanceof Drawable) a.ctick(dt2); else a.ctick(dt); } for (Iterator<Overlay> i = ols.iterator(); i.hasNext(); ) { Overlay ol = i.next(); if (ol.spr == null) { if (((getattr(Drawable.class) == null) || (getneg() != null)) && (ol.res.get() != null)) ol.spr = Sprite.create(this, ol.res.get(), ol.sdt); } else { boolean done = ol.spr.tick(dt); if ((!ol.delign || (ol.spr instanceof Overlay.CDel)) && done) i.remove(); } } }
void drawAllROIs(Graphics g) { RoiManager rm = RoiManager.getInstance(); if (rm == null) { rm = Interpreter.getBatchModeRoiManager(); if (rm != null && rm.getList().getItemCount() == 0) rm = null; } if (rm == null) { // if (showAllList!=null) // overlay = showAllList; showAllROIs = false; repaint(); return; } initGraphics(g, null, showAllColor); Hashtable rois = rm.getROIs(); java.awt.List list = rm.getList(); boolean drawLabels = rm.getDrawLabels(); currentRoi = null; int n = list.getItemCount(); if (IJ.debugMode) IJ.log("paint: drawing " + n + " \"Show All\" ROIs"); if (labelRects == null || labelRects.length != n) labelRects = new Rectangle[n]; if (!drawLabels) showAllList = new Overlay(); else showAllList = null; if (imp == null) return; int currentImage = imp.getCurrentSlice(); int channel = 0, slice = 0, frame = 0; boolean hyperstack = imp.isHyperStack(); if (hyperstack) { channel = imp.getChannel(); slice = imp.getSlice(); frame = imp.getFrame(); } drawNames = Prefs.useNamesAsLabels; for (int i = 0; i < n; i++) { String label = list.getItem(i); Roi roi = (Roi) rois.get(label); if (roi == null) continue; if (showAllList != null) showAllList.add(roi); if (i < 200 && drawLabels && roi == imp.getRoi()) currentRoi = roi; if (Prefs.showAllSliceOnly && imp.getStackSize() > 1) { if (hyperstack && roi.getPosition() == 0) { int c = roi.getCPosition(); int z = roi.getZPosition(); int t = roi.getTPosition(); if ((c == 0 || c == channel) && (z == 0 || z == slice) && (t == 0 || t == frame)) drawRoi(g, roi, drawLabels ? i : -1); } else { int position = roi.getPosition(); if (position == 0) position = getSliceNumber(roi.getName()); if (position == 0 || position == currentImage) drawRoi(g, roi, drawLabels ? i : -1); } } else drawRoi(g, roi, drawLabels ? i : -1); } ((Graphics2D) g).setStroke(Roi.onePixelWide); drawNames = false; }
public boolean equals(Object other) { if (other instanceof Overlay == false) { return false; } Overlay otherOverlay = (Overlay) other; if (m_addOrder.length != otherOverlay.getAddOrder().length) { return false; } for (int i = 0; i < m_parents.length; i++) { if (m_parents[i] != otherOverlay.getParents()[i]) { return false; } } return true; }
@SuppressWarnings("unused") private void toggle() { QWidget current = panels.currentWidget(); QWidget next = panels.widget((panels.currentIndex() + 1) % 2); // make sure the layout is up to date... next.setGeometry(current.geometry()); QPixmap startpm = QPixmap.grabWidget(current); QPixmap endpm = QPixmap.grabWidget(next); Overlay overlay = new Overlay(startpm, endpm); overlay.setTransition(transition); overlay.setParent(this); overlay.setGeometry(panels.geometry()); overlay.show(); panels.setCurrentIndex((panels.currentIndex() + 1) % 2); }
void fromRoiManager() { ImagePlus imp = IJ.getImage(); RoiManager rm = RoiManager.getInstance(); if (rm == null) { IJ.error("ROI Manager is not open"); return; } Roi[] rois = rm.getRoisAsArray(); if (rois.length == 0) { IJ.error("ROI Manager is empty"); return; } Overlay overlay = new Overlay(); for (int i = 0; i < rois.length; i++) overlay.add((Roi) rois[i].clone()); imp.setOverlay(overlay); ImageCanvas ic = imp.getCanvas(); if (ic != null) ic.setShowAllROIs(false); rm.setEditMode(imp, false); imp.killRoi(); }
private boolean deleteOverlayRoi(ImagePlus imp) { if (imp == null) return false; Overlay overlay = null; ImageCanvas ic = imp.getCanvas(); if (ic != null) overlay = ic.getShowAllList(); if (overlay == null) overlay = imp.getOverlay(); if (overlay == null) return false; Roi roi = imp.getRoi(); for (int i = 0; i < overlay.size(); i++) { Roi roi2 = overlay.get(i); if (roi2 == roi) { overlay.remove(i); imp.deleteRoi(); ic = imp.getCanvas(); if (ic != null) ic.roiManagerSelect(roi, true); return true; } } return false; }
public void paint(Graphics g) { if (backBufferWidth != getSize().width || backBufferHeight != getSize().height || backBufferImage == null || backBufferGraphics == null) resetBackBuffer(); final Rectangle src = getSrcRect(); synchronized (this) { super.paint(backBufferGraphics); for (Overlay overlay : overlays) overlay.paint(backBufferGraphics, src.x, src.y, magnification); final Roi roi = super.imp.getRoi(); if (roi != null) roi.draw(backBufferGraphics); } g.drawImage(backBufferImage, 0, 0, this); }
// Added by Marcel Boeglin 2013.09.22 private Overlay projectRGBHyperStackRois(Overlay overlay) { if (overlay == null) return null; int frames = projImage.getNFrames(); int t1 = imp.getFrame(); Overlay overlay2 = new Overlay(); Roi roi; int c, z, t; for (Roi r : overlay.toArray()) { c = r.getCPosition(); z = r.getZPosition(); t = r.getTPosition(); roi = (Roi) r.clone(); if (z >= startSlice && z <= stopSlice || z == 0 || c == 0 || t == 0) { if (frames == 1 && t != t1 && t != 0) // current time frame continue; roi.setPosition(t); overlay2.add(roi); } } return overlay2; }
public void draw(Canvas canvas, MapView mapview, boolean flag) { Projection projection = mapview.getProjection(); Paint paint = new Paint(); Point point = new Point(); projection.toPixels(gp1, point); paint.setColor(color); Point point1 = new Point(); projection.toPixels(gp2, point1); paint.setStrokeWidth(5F); paint.setAlpha(120); canvas.drawLine(point.x, point.y, point1.x, point1.y, paint); super.draw(canvas, mapview, flag); }
public static void main(String[] args) { if (args.length > 0) { String command = args[0]; String[] arguments = new String[args.length - 1]; System.arraycopy(args, 1, arguments, 0, arguments.length); boolean exitAfterCallingMain = true; try { if (command.equals("ConvertColorspace")) { ConvertColorspace.main(arguments); } else if (command.equals("Decrypt")) { Decrypt.main(arguments); } else if (command.equals("Encrypt")) { Encrypt.main(arguments); } else if (command.equals("ExtractText")) { ExtractText.main(arguments); } else if (command.equals("Overlay")) { Overlay.main(arguments); } else if (command.equals("PrintPDF")) { PrintPDF.main(arguments); } else if (command.equals("PDFDebugger")) { PDFDebugger.main(arguments); exitAfterCallingMain = false; } else if (command.equals("PDFMerger")) { PDFMerger.main(arguments); } else if (command.equals("PDFReader")) { PDFReader.main(arguments); exitAfterCallingMain = false; } else if (command.equals("PDFSplit")) { PDFSplit.main(arguments); } else if (command.equals("PDFToImage")) { PDFToImage.main(arguments); } else if (command.equals("TextToPDF")) { TextToPDF.main(arguments); } else if (command.equals("WriteDecodedDoc")) { WriteDecodedDoc.main(arguments); } else { showMessageAndExit(); } if (exitAfterCallingMain) { System.exit(0); } } catch (Exception e) { System.err.println(command + " failed with the following exception:"); e.printStackTrace(); System.exit(1); } } else { showMessageAndExit(); } }