DrawingPanel renders drawable objects on its canvas. DrawingPanel provides drawable objects with methods that transform from world coordinates to pixel coordinates. World coordinates are defined by xmin, xmax, ymin, and ymax. These values are recalculated on-the-fly from preferred values if the aspe
| 82 | * @version 1.0 |
| 83 | */ |
| 84 | @SuppressWarnings("serial") |
| 85 | public class DrawingPanel extends JPanel implements Disposable, ActionListener, Renderable { |
| 86 | |
| 87 | static int ntest; |
| 88 | |
| 89 | public static final boolean messagesAsJLabels = true; |
| 90 | |
| 91 | protected static boolean RECORD_PAINT_TIMES = false; // set true to test painting time |
| 92 | protected long currentTime;// = System.currentTimeMillis(); |
| 93 | |
| 94 | @Deprecated |
| 95 | public static final int BOTTOM_LEFT = MessageDrawable.BOTTOM_LEFT; |
| 96 | @Deprecated |
| 97 | public static final int BOTTOM_RIGHT = MessageDrawable.BOTTOM_RIGHT; |
| 98 | @Deprecated |
| 99 | public static final int TOP_RIGHT = MessageDrawable.TOP_RIGHT; |
| 100 | @Deprecated |
| 101 | public static final int TOP_LEFT = MessageDrawable.TOP_LEFT; |
| 102 | |
| 103 | public boolean isInteractive; |
| 104 | |
| 105 | protected boolean isDisposed; |
| 106 | |
| 107 | /** |
| 108 | * BH experimental -- not needed. |
| 109 | */ |
| 110 | private JPanel glassPane; |
| 111 | |
| 112 | public JPanel getGlassPane() { |
| 113 | return (glassPane == null ? this : glassPane); |
| 114 | } |
| 115 | |
| 116 | protected JPopupMenu popupmenu; // right mouse click popup menu |
| 117 | /** |
| 118 | * |
| 119 | * the menu items for the box |
| 120 | * |
| 121 | */ |
| 122 | protected JMenuItem propertiesItem, autoscaleItem, scaleItem, zoomInItem, zoomOutItem, snapshotItem; |
| 123 | |
| 124 | protected int leftGutter = 0, topGutter = 0, rightGutter = 0, bottomGutter = 0; |
| 125 | protected int leftGutterPreferred = 0, topGutterPreferred = 0, rightGutterPreferred = 0, bottomGutterPreferred = 0; |
| 126 | protected boolean clipAtGutter = true; // clips the drawing at the gutter if true |
| 127 | protected boolean adjustableGutter = false; // adjust gutter depending on panel size |
| 128 | protected int lastWidth, lastHeight; // the size of the panel the last time it was painted. |
| 129 | protected Color bgColor = new Color(239, 239, 255); // background color |
| 130 | protected boolean antialiasTextOn = false; |
| 131 | protected boolean antialiasShapeOn = false; |
| 132 | protected boolean squareAspect = false; // adjust xAspect and yAspect so the drawing aspect ratio is unity |
| 133 | protected boolean autoscaleX = true; |
| 134 | protected boolean autoscaleY = true; |
| 135 | protected boolean autoscaleXMin = true, autoscaleXMax = true; |
| 136 | protected boolean autoscaleYMin = true, autoscaleYMax = true; |
| 137 | protected double autoscaleMargin = 0.0; // used to increase the autoscale range |
| 138 | // x and y scale in world units |
| 139 | protected double xminPreferred = -10.0, xmaxPreferred = 10.0; |
| 140 | protected double yminPreferred = -10.0, ymaxPreferred = 10.0; |
| 141 | protected double xfloor = Double.NaN, xceil = Double.NaN; |
nothing calls this directly
no test coverage detected