MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / showRangeArrows

Method showRangeArrows

ij/src/main/java/ij/gui/PlotWindow.java:712–782  ·  view source on GitHub ↗

Creates an overlay with triangular buttons and othr symbols for changing the axis range limits and shows it

()

Source from the content-addressed store, hash-verified

710 * limits and shows it
711 */
712 @AstroImageJ(reason = "Support scaled plots", modified = true)
713 void showRangeArrows() {
714 if (imp == null)
715 return;
716 hideRangeArrows(); //in case we have old arrows from a different plot size or so
717 rangeArrowRois = new Roi[4 * 2 + 2 + 4 + 2]; //4 arrows per axis, + 'Reset' and 'Fit All' icons, + 4 numerical input boxes + 2 axes
718 int i = 0;
719 int height = imp.getHeight();
720 if (plot.isAijPlot()) {
721 height = (int) (height / Prefs.getGuiScale());
722 }
723 int arrowH = plot.topMargin < 14 ? 6 : 8; //height of arrows and distance between them; base is twice that value
724 float[] yP = new float[]{height - arrowH / 2, height - 3 * arrowH / 2, height - 5 * arrowH / 2 - 0.1f};
725
726 for (float x : new float[]{plot.leftMargin, plot.leftMargin + plot.frameWidth}) { //create arrows for x axis
727 float[] x0 = new float[]{x - arrowH / 2, x - 3 * arrowH / 2 - 0.1f, x - arrowH / 2};
728 rangeArrowRois[i++] = new PolygonRoi(x0, yP, 3, Roi.POLYGON);
729 float[] x1 = new float[]{x + arrowH / 2, x + 3 * arrowH / 2 + 0.1f, x + arrowH / 2};
730 rangeArrowRois[i++] = new PolygonRoi(x1, yP, 3, Roi.POLYGON);
731 }
732 float[] xP = new float[]{arrowH / 2 - 0.1f, 3 * arrowH / 2, 5 * arrowH / 2 + 0.1f};
733 for (float y : new float[]{plot.topMargin + plot.frameHeight, plot.topMargin}) { //create arrows for y axis
734 float[] y0 = new float[]{y + arrowH / 2, y + 3 * arrowH / 2 + 0.1f, y + arrowH / 2};
735 rangeArrowRois[i++] = new PolygonRoi(xP, y0, 3, Roi.POLYGON);
736 float[] y1 = new float[]{y - arrowH / 2, y - 3 * arrowH / 2 - 0.1f, y - arrowH / 2};
737 rangeArrowRois[i++] = new PolygonRoi(xP, y1, 3, Roi.POLYGON);
738 }
739 Font theFont = new Font("SansSerif", Font.BOLD, 13);
740
741 TextRoi txtRoi = new TextRoi(1, height - 19, "\u2009R\u2009", theFont); //thin spaces to make roi slightly wider
742 rangeArrowRois[8] = txtRoi;
743 TextRoi txtRoi2 = new TextRoi(20, height - 19, "\u2009F\u2009", theFont);
744 rangeArrowRois[9] = txtRoi2;
745
746 rangeArrowRois[10] = new Roi(plot.leftMargin - arrowH/2 + 1, height - 5 * arrowH / 2, arrowH - 2, arrowH * 2);//numerical box left
747 rangeArrowRois[11] = new Roi(plot.leftMargin + plot.frameWidth - arrowH/2 + 1, height - 5 * arrowH / 2, arrowH - 2, arrowH * 2);//numerical box right
748 rangeArrowRois[12] = new Roi(arrowH / 2, plot.topMargin + plot.frameHeight - arrowH/2 + 1, arrowH * 2, arrowH -2);//numerical box bottom
749 rangeArrowRois[13] = new Roi(arrowH / 2, plot.topMargin - arrowH/2 + 1, arrowH * 2, arrowH - 2 );//numerical box top
750
751 int topMargin = plot.topMargin;
752 int bottomMargin = topMargin + plot.frameHeight;
753 int leftMargin = plot.leftMargin;
754 int rightMargin = plot.leftMargin + plot.frameWidth;
755 rangeArrowRois[14] = new Roi(leftMargin, bottomMargin+2, // area to click for x axis options
756 rightMargin - leftMargin + 1, 2*arrowH);
757 rangeArrowRois[15] = new Roi(leftMargin-2*arrowH-2, topMargin, // area to click for y axis options
758 2*arrowH, bottomMargin - topMargin + 1);
759
760 for (int i1 = 0; plot.isAijPlot() && i1 < rangeArrowRois.length; i1++) {
761 var isRect = rangeArrowRois[i1].type == Roi.RECTANGLE;
762 rangeArrowRois[i1] = RoiScaler.scale(rangeArrowRois[i1], Prefs.getGuiScale(), Prefs.getGuiScale(), false);
763 rangeArrowRois[i1].setProperty("aijScaledRect", "" + isRect);
764 }
765
766 Overlay ovly = imp.getOverlay();
767 if (ovly == null)
768 ovly = new Overlay();
769 for (Roi roi : rangeArrowRois) {

Callers 1

mouseMovedMethod · 0.95

Calls 14

hideRangeArrowsMethod · 0.95
getGuiScaleMethod · 0.95
scaleMethod · 0.95
addMethod · 0.95
isAijPlotMethod · 0.80
getHeightMethod · 0.45
setPropertyMethod · 0.45
getOverlayMethod · 0.45
equalsMethod · 0.45
getPropertyMethod · 0.45
setFillColorMethod · 0.45
setStrokeColorMethod · 0.45

Tested by

no test coverage detected