/** * Returns the FontBBox value as integer array. * @return the font's bounding box */ public int[] getFontBBoxAsIntArray() { RectangularShape rect = getFontBBox(); return new int[] { (int)Math.floor(rect.getMinX()), (int)Math.floor(rect.getMinY()), (int)Math.ceil(rect.getMaxX()), (int)Math.ceil(rect.getMaxY())}; }
GraphicsDevice defaultScreen = ge.getDefaultScreenDevice(); Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds(); int x = (int) rect.getMaxX() - f.getWidth(); int y = (int) rect.getMaxY() - f.getHeight(); f.setLocation(x, y);
/** * Returns the maximum <var>x</var> coordinate of the rectangle * (the logical coordinate, not the pixel coordinate). */ public double getMaxX() { return logicalShape.getMaxX(); }
/** * Returns the FontBBox value as integer array. * @return the font's bounding box */ public int[] getFontBBoxAsIntArray() { RectangularShape rect = getFontBBox(); return new int[] { (int)Math.floor(rect.getMinX()), (int)Math.floor(rect.getMinY()), (int)Math.ceil(rect.getMaxX()), (int)Math.ceil(rect.getMaxY())}; }
/** * Returns the FontBBox value as integer array. * @return the font's bounding box */ public int[] getFontBBoxAsIntArray() { RectangularShape rect = getFontBBox(); return new int[] { (int)Math.floor(rect.getMinX()), (int)Math.floor(rect.getMinY()), (int)Math.ceil(rect.getMaxX()), (int)Math.ceil(rect.getMaxY())}; }
float maxx = (float)rect.getMaxX(); float maxy = (float)rect.getMaxY();
protected boolean isSelected(RectangularShape rectangle, float mouseX, float mouseY) { return mouseX >= rectangle.getMinX() && mouseY >= rectangle.getMinY() && mouseX < rectangle.getMaxX() && mouseY < rectangle.getMaxY(); }
@Override public void mouseWheelMoved(MouseWheelEvent e) { if (e.isConsumed()) { return; } Point2D.Double mouseLoc = new Point2D.Double(e.getPoint().x, e.getPoint().y); // ensure the point is within the window RectangularShape bounds = component.getBounds(); mouseLoc.x = Math.max(mouseLoc.x, bounds.getMinX()); mouseLoc.x = Math.min(mouseLoc.x, bounds.getMaxX()); mouseLoc.y = Math.max(mouseLoc.y, bounds.getMinY()); mouseLoc.y = Math.min(mouseLoc.y, bounds.getMaxY()); zoomPoint(component, component.toGraphicCoordinate(mouseLoc), (e.getWheelRotation() > 0) ? 1.05 : 0.95); }
/** * Called each time the position of the rectangle is adjusted. This * method will adjust the value displayed in the text field * based on the position of the rectangle. */ private void updateText(final JFormattedTextField editor) { String text; if (!logicalShape.isEmpty() || ((text = editor.getText()) != null && text.trim().length() != 0)) { double value; switch (inverseTransform(side)) { case NORTH: value = logicalShape.getMinY(); break; case SOUTH: value = logicalShape.getMaxY(); break; case WEST: value = logicalShape.getMinX(); break; case EAST: value = logicalShape.getMaxX(); break; default : return; } editor.setValue(isDate ? (Object) new Date(Math.round(value)) : (Object) new Double(value)); } }
GraphicsDevice defaultScreen = ge.getDefaultScreenDevice(); Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds(); int x = (int) rect.getMaxX() - f.getWidth(); int y = 0; f.setLocation(x, y);
shape.setFrame(x, y, width, height); if (enforceWidth) { if (!first && shape.getMaxX() > maxX) { x = minX; y += verticalSpacing + levelHeight;
double yOffset, RectangleEdge base, boolean pegShadow) { double x0 = bar.getMinX(); double x1 = bar.getMaxX(); double y0 = bar.getMinY(); double y1 = bar.getMaxY();
/** * Update the (x,y) and width height boundary of this view * * Implemented because the canvas has no layout manager */ @Override public void updateBounds() { super.updateBounds(); // TOP-LEFT dragPoints.get(0).setLocation(noteRect.getMinX(), noteRect.getMinY()); // TOP-MIDDLE dragPoints.get(1).setLocation(noteRect.getCenterX(), noteRect.getMinY()); // TOP-RIGHT dragPoints.get(2).setLocation(noteRect.getMaxX(), noteRect.getMinY()); // MIDDLE-RIGHT dragPoints.get(3).setLocation(noteRect.getMaxX(), noteRect.getCenterY()); // BOTTOM-RIGHT dragPoints.get(4).setLocation(noteRect.getMaxX(), noteRect.getMaxY()); // BOTTOM-MIDDLE dragPoints.get(5).setLocation(noteRect.getCenterX(), noteRect.getMaxY()); // BOTTOM-LEFT dragPoints.get(6).setLocation(noteRect.getMinX(), noteRect.getMaxY()); // MIDDLE-LEFT dragPoints.get(7).setLocation(noteRect.getMinX(), noteRect.getCenterY()); }
/** * Splits a bar into subregions (elsewhere, these subregions will have * different gradients applied to them). * * @param bar the bar shape. * @param a the first division. * @param b the second division. * @param c the third division. * * @return An array containing four subregions. */ private Rectangle2D[] splitVerticalBar(RectangularShape bar, double a, double b, double c) { Rectangle2D[] result = new Rectangle2D[4]; double x0 = bar.getMinX(); double x1 = Math.rint(x0 + (bar.getWidth() * a)); double x2 = Math.rint(x0 + (bar.getWidth() * b)); double x3 = Math.rint(x0 + (bar.getWidth() * c)); result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), x1 - x0, bar.getHeight()); result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1, bar.getHeight()); result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2, bar.getHeight()); result[3] = new Rectangle2D.Double(x3, bar.getMinY(), bar.getMaxX() - x3, bar.getHeight()); return result; }
/** * Splits a bar into subregions (elsewhere, these subregions will have * different gradients applied to them). * * @param bar the bar shape. * @param a the first division. * @param b the second division. * @param c the third division. * * @return An array containing four subregions. */ private Rectangle2D[] splitVerticalBar(RectangularShape bar, double a, double b, double c) { Rectangle2D[] result = new Rectangle2D[4]; double x0 = bar.getMinX(); double x1 = Math.rint(x0 + (bar.getWidth() * a)); double x2 = Math.rint(x0 + (bar.getWidth() * b)); double x3 = Math.rint(x0 + (bar.getWidth() * c)); result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), x1 - x0, bar.getHeight()); result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1, bar.getHeight()); result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2, bar.getHeight()); result[3] = new Rectangle2D.Double(x3, bar.getMinY(), bar.getMaxX() - x3, bar.getHeight()); return result; }
/** * Splits a bar into subregions (elsewhere, these subregions will have * different gradients applied to them). * * @param bar the bar shape. * @param a the first division. * @param b the second division. * @param c the third division. * * @return An array containing four subregions. */ private Rectangle2D[] splitVerticalBar(RectangularShape bar, double a, double b, double c) { Rectangle2D[] result = new Rectangle2D[4]; double x0 = bar.getMinX(); double x1 = Math.rint(x0 + (bar.getWidth() * a)); double x2 = Math.rint(x0 + (bar.getWidth() * b)); double x3 = Math.rint(x0 + (bar.getWidth() * c)); result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), x1 - x0, bar.getHeight()); result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1, bar.getHeight()); result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2, bar.getHeight()); result[3] = new Rectangle2D.Double(x3, bar.getMinY(), bar.getMaxX() - x3, bar.getHeight()); return result; }
* (feeltraceShape.getMaxX() - feeltraceShape.getCenterX()) / normalizedModel.getMaxX()); int y = (int) (feeltraceShape.getCenterY() - normalizedModel.getY()
/** * Splits a bar into subregions (elsewhere, these subregions will have * different gradients applied to them). * * @param bar the bar shape. * @param a the first division. * @param b the second division. * @param c the third division. * * @return An array containing four subregions. */ private Rectangle2D[] splitVerticalBar(RectangularShape bar, double a, double b, double c) { Rectangle2D[] result = new Rectangle2D[4]; double x0 = bar.getMinX(); double x1 = Math.rint(x0 + (bar.getWidth() * a)); double x2 = Math.rint(x0 + (bar.getWidth() * b)); double x3 = Math.rint(x0 + (bar.getWidth() * c)); result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), x1 - x0, bar.getHeight()); result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1, bar.getHeight()); result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2, bar.getHeight()); result[3] = new Rectangle2D.Double(x3, bar.getMinY(), bar.getMaxX() - x3, bar.getHeight()); return result; }
/** * Asserts that two rectangles have the same location and the same size. * * @param expected the expected rectangle. * @param actual the rectangle to compare with the expected one. * @param tolx the tolerance threshold on location along the <var>x</var> axis. * @param toly the tolerance threshold on location along the <var>y</var> axis. */ public static void assertRectangleEquals(final RectangularShape expected, final RectangularShape actual, final double tolx, final double toly) { assertEquals("Min X", expected.getMinX(), actual.getMinX(), tolx); assertEquals("Min Y", expected.getMinY(), actual.getMinY(), toly); assertEquals("Max X", expected.getMaxX(), actual.getMaxX(), tolx); assertEquals("Max Y", expected.getMaxY(), actual.getMaxY(), toly); assertEquals("Center X", expected.getCenterX(), actual.getCenterX(), tolx); assertEquals("Center Y", expected.getCenterY(), actual.getCenterY(), toly); assertEquals("Width", expected.getWidth(), actual.getWidth(), tolx*2); assertEquals("Height", expected.getHeight(), actual.getHeight(), toly*2); }