/** * Sets new point shape. Bound property. * @param pointShape new Shape. */ public final void setPointShape(Shape pointShape) { Shape old = getPointShape(); this.pointShape = pointShape; if (getPointShape() != old && getPointShape() != null && !getPointShape().equals(old)) { firePropertyChange("pointShape", old, getPointShape()); } }
/** * Sets new point shape. Bound property. * @param pointShape new Shape. */ public final void setPointShape(Shape pointShape) { Shape old = getPointShape(); this.pointShape = pointShape; firePropertyChange("pointShape", old, getPointShape()); }
/** * Sets new point shape. Bound property. * @param pointShape new Shape. */ public final void setPointShape(Shape pointShape) { Shape old = getPointShape(); this.pointShape = pointShape; firePropertyChange("pointShape", old, getPointShape()); }
/** * Sets new point shape. Bound property. * @param pointShape new Shape. */ public final void setPointShape(Shape pointShape) { Shape old = getPointShape(); this.pointShape = pointShape; firePropertyChange("pointShape", old, getPointShape()); }
private void paintRotatedCenteredShapeAtPoint(Float p, Float c, Graphics2D g) { Shape s = getPointShape(); double hh = s.getBounds().getHeight() / 2; double wh = s.getBounds().getWidth() / 2; double t, x, y; double a = c.y - p.y; double b = p.x - c.x; double sa = Math.signum(a); double sb = Math.signum(b); sa = sa == 0 ? 1 : sa; sb = sb == 0 ? 1 : sb; a = Math.abs(a); b = Math.abs(b); t = Math.atan(a / b); t = sa > 0 ? sb > 0 ? -t : -Math.PI + t : sb > 0 ? t : Math.PI - t; x = Math.sqrt(a * a + b * b) - wh; y = -hh; g.rotate(t); g.translate(x, y); g.fill(s); g.translate(-x, -y); g.rotate(-t); }
private void paintRotatedCenteredShapeAtPoint(Float p, Float c, Graphics2D g) { Shape s = getPointShape(); double hh = s.getBounds().getHeight() / 2; double wh = s.getBounds().getWidth() / 2; double t, x, y; double a = c.y - p.y; double b = p.x - c.x; double sa = Math.signum(a); double sb = Math.signum(b); sa = sa == 0 ? 1 : sa; sb = sb == 0 ? 1 : sb; a = Math.abs(a); b = Math.abs(b); t = Math.atan(a / b); t = sa > 0 ? sb > 0 ? -t : -Math.PI + t : sb > 0 ? t : Math.PI - t; x = Math.sqrt(a * a + b * b) - wh; y = -hh; g.rotate(t); g.translate(x, y); g.fill(s); g.translate(-x, -y); g.rotate(-t); }
private void paintRotatedCenteredShapeAtPoint(Float p, Float c, Graphics2D g) { Shape s = getPointShape(); double hh = s.getBounds().getHeight() / 2; double wh = s.getBounds().getWidth() / 2; double t, x, y; double a = c.y - p.y; double b = p.x - c.x; double sa = Math.signum(a); double sb = Math.signum(b); sa = sa == 0 ? 1 : sa; sb = sb == 0 ? 1 : sb; a = Math.abs(a); b = Math.abs(b); t = Math.atan(a / b); t = sa > 0 ? sb > 0 ? -t : -Math.PI + t : sb > 0 ? t : Math.PI - t; x = Math.sqrt(a * a + b * b) - wh; y = -hh; g.rotate(t); g.translate(x, y); g.fill(s); g.translate(-x, -y); g.rotate(-t); }
private void paintRotatedCenteredShapeAtPoint(Float p, Float c, Graphics2D g) { Shape s = getPointShape(); double hh = s.getBounds().getHeight() / 2; double wh = s.getBounds().getWidth() / 2; double t, x, y; double a = c.y - p.y; double b = p.x - c.x; double sa = Math.signum(a); double sb = Math.signum(b); sa = sa == 0 ? 1 : sa; sb = sb == 0 ? 1 : sb; a = Math.abs(a); b = Math.abs(b); t = Math.atan(a / b); t = sa > 0 ? sb > 0 ? -t : -Math.PI + t : sb > 0 ? t : Math.PI - t; x = Math.sqrt(a * a + b * b) - wh; y = -hh; g.rotate(t); g.translate(x, y); g.fill(s); g.translate(-x, -y); g.rotate(-t); }
/** * Returns the current BusyPainter. If no BusyPainter is currently * set on this BusyLabel, the {@link #createBusyPainter(Dimension)} * method is called to create one. Afterwards, * {@link #initPainter(Dimension)} is called to update the BusyLabel * with the created BusyPainter. * * @return the busyPainter * * @see #createBusyPainter(Dimension) * @see #initPainter(Dimension) */ public final BusyPainter getBusyPainter() { if (null == busyPainter) { Dimension prefSize = getPreferredSize(); busyPainter = createBusyPainter((prefSize.width == 0 && prefSize.height == 0 && !isPreferredSizeSet()) ? null : prefSize); if (null != busyPainter) { if (!isPreferredSizeSet() && (null == prefSize || prefSize.width == 0 || prefSize.height == 0)) { Rectangle rt = busyPainter.getTrajectory().getBounds(); Rectangle rp = busyPainter.getPointShape().getBounds(); int max = Math.max(rp.width, rp.height); prefSize = new Dimension(rt.width + max, rt.height + max); } initPainter(prefSize); } } return busyPainter; }
/** * Returns the current BusyPainter. If no BusyPainter is currently * set on this BusyLabel, the {@link #createBusyPainter(Dimension)} * method is called to create one. Afterwards, * {@link #initPainter(Dimension)} is called to update the BusyLabel * with the created BusyPainter. * * @return the busyPainter * * @see #createBusyPainter(Dimension) * @see #initPainter(Dimension) */ public final BusyPainter getBusyPainter() { if (null == busyPainter) { Dimension prefSize = getPreferredSize(); busyPainter = createBusyPainter((prefSize.width == 0 && prefSize.height == 0 && !isPreferredSizeSet()) ? null : prefSize); if (null != busyPainter) { if (!isPreferredSizeSet() && (null == prefSize || prefSize.width == 0 || prefSize.height == 0)) { Rectangle rt = busyPainter.getTrajectory().getBounds(); Rectangle rp = busyPainter.getPointShape().getBounds(); int max = Math.max(rp.width, rp.height); prefSize = new Dimension(rt.width + max, rt.height + max); } initPainter(prefSize); } } return busyPainter; }
/** * Returns the current BusyPainter. If no BusyPainter is currently * set on this BusyLabel, the {@link #createBusyPainter(Dimension)} * method is called to create one. Afterwards, * {@link #initPainter(Dimension)} is called to update the BusyLabel * with the created BusyPainter. * * @return the busyPainter * * @see #createBusyPainter(Dimension) * @see #initPainter(Dimension) */ public final BusyPainter getBusyPainter() { if (null == busyPainter) { Dimension prefSize = getPreferredSize(); busyPainter = createBusyPainter((prefSize.width == 0 && prefSize.height == 0 && !isPreferredSizeSet()) ? null : prefSize); if (null != busyPainter) { if (!isPreferredSizeSet() && (null == prefSize || prefSize.width == 0 || prefSize.height == 0)) { Rectangle rt = busyPainter.getTrajectory().getBounds(); Rectangle rp = busyPainter.getPointShape().getBounds(); int max = Math.max(rp.width, rp.height); prefSize = new Dimension(rt.width + max, rt.height + max); } initPainter(prefSize); } } return busyPainter; }
/** * Returns the current BusyPainter. If no BusyPainter is currently * set on this BusyLabel, the {@link #createBusyPainter(Dimension)} * method is called to create one. Afterwards, * {@link #initPainter(Dimension)} is called to update the BusyLabel * with the created BusyPainter. * * @return the busyPainter * * @see #createBusyPainter(Dimension) * @see #initPainter(Dimension) */ public final BusyPainter getBusyPainter() { if (null == busyPainter) { Dimension prefSize = getPreferredSize(); busyPainter = createBusyPainter((prefSize.width == 0 && prefSize.height == 0 && !isPreferredSizeSet()) ? null : prefSize); if (null != busyPainter) { if (!isPreferredSizeSet() && (null == prefSize || prefSize.width == 0 || prefSize.height == 0)) { Rectangle rt = busyPainter.getTrajectory().getBounds(); Rectangle rp = busyPainter.getPointShape().getBounds(); int max = Math.max(rp.width, rp.height); prefSize = new Dimension(rt.width + max, rt.height + max); } initPainter(prefSize); } } return busyPainter; }
/** * Returns the current BusyPainter. If no BusyPainter is currently * set on this BusyLabel, the {@link #createBusyPainter(Dimension)} * method is called to create one. Afterwards, * {@link #initPainter(Dimension)} is called to update the BusyLabel * with the created BusyPainter. * * @return the busyPainter * * @see #createBusyPainter(Dimension) * @see #initPainter(Dimension) */ public final BusyPainter getBusyPainter() { if (null == busyPainter) { Dimension prefSize = getPreferredSize(); busyPainter = createBusyPainter((prefSize.width == 0 && prefSize.height == 0 && !isPreferredSizeSet()) ? null : prefSize); if (null != busyPainter) { if (!isPreferredSizeSet() && (null == prefSize || prefSize.width == 0 || prefSize.height == 0)) { Rectangle rt = busyPainter.getTrajectory().getBounds(); Rectangle rp = busyPainter.getPointShape().getBounds(); int max = Math.max(rp.width, rp.height); prefSize = new Dimension(rt.width + max, rt.height + max); } initPainter(prefSize); } } return busyPainter; }
@Test @Override public void testDefaults() { super.testDefaults(); BusyPainter bp = (BusyPainter) p; assertThat(bp.getBaseColor(), is(Color.LIGHT_GRAY)); assertThat(bp.getDirection(), is(BusyPainter.Direction.RIGHT)); assertThat(bp.getFrame(), is(-1)); assertThat(bp.getHighlightColor(), is(Color.BLACK)); assertThat(bp.getPoints(), is(8)); assertThat(bp.getPointShape(), is(BusyPainter.getScaledDefaultPoint(26))); assertThat(bp.getTrailLength(), is(4)); assertThat(bp.getTrajectory(), is(BusyPainter.getScaledDefaultTrajectory(26))); assertThat(bp.isPaintCentered(), is(false)); } }