/** * Sets length of the trail in points. Bound property. * @param trailLength Trail length in points. */ public void setTrailLength(int trailLength) { int old = getTrailLength(); this.trailLength = trailLength; firePropertyChange("trailLength", old, getTrailLength()); }
/** * Sets length of the trail in points. Bound property. * @param trailLength Trail length in points. */ public void setTrailLength(int trailLength) { int old = getTrailLength(); this.trailLength = trailLength; firePropertyChange("trailLength", old, getTrailLength()); }
/** * Sets length of the trail in points. Bound property. * @param trailLength Trail length in points. */ public void setTrailLength(int trailLength) { int old = getTrailLength(); this.trailLength = trailLength; firePropertyChange("trailLength", old, getTrailLength()); }
/** * Sets length of the trail in points. Bound property. * @param trailLength Trail length in points. */ public void setTrailLength(int trailLength) { int old = getTrailLength(); this.trailLength = trailLength; firePropertyChange("trailLength", old, getTrailLength()); }
/** * Selects appropriate color for given frame based on the frame position and gradient difference. * @param i Frame. * @return Frame color. */ private Color calcFrameColor(final int i) { if (frame == -1) { return getBaseColor(); } for (int t = 0; t < getTrailLength(); t++) { if (direction == Direction.RIGHT && i == (frame - t + getPoints()) % getPoints()) { float terp = 1 - ((float) (getTrailLength() - t)) / (float) getTrailLength(); return PaintUtils.interpolate(getBaseColor(), getHighlightColor(), terp); } else if (direction == Direction.LEFT && i == (frame + t) % getPoints()) { float terp = ((float) (t)) / (float) getTrailLength(); return PaintUtils.interpolate(getBaseColor(), getHighlightColor(), terp); } } return getBaseColor(); }
/** * Selects appropriate color for given frame based on the frame position and gradient difference. * @param i Frame. * @return Frame color. */ private Color calcFrameColor(final int i) { if (frame == -1) { return getBaseColor(); } for (int t = 0; t < getTrailLength(); t++) { if (direction == Direction.RIGHT && i == (frame - t + getPoints()) % getPoints()) { float terp = 1 - ((float) (getTrailLength() - t)) / (float) getTrailLength(); return PaintUtils.interpolate(getBaseColor(), getHighlightColor(), terp); } else if (direction == Direction.LEFT && i == (frame + t) % getPoints()) { float terp = ((float) (t)) / (float) getTrailLength(); return PaintUtils.interpolate(getBaseColor(), getHighlightColor(), terp); } } return getBaseColor(); }
/** * Selects appropriate color for given frame based on the frame position and gradient difference. * @param i Frame. * @return Frame color. */ private Color calcFrameColor(final int i) { if (frame == -1) { return getBaseColor(); } for (int t = 0; t < getTrailLength(); t++) { if (direction == Direction.RIGHT && i == (frame - t + getPoints()) % getPoints()) { float terp = 1 - ((float) (getTrailLength() - t)) / (float) getTrailLength(); return PaintUtils.interpolate(getBaseColor(), getHighlightColor(), terp); } else if (direction == Direction.LEFT && i == (frame + t) % getPoints()) { float terp = ((float) (t)) / (float) getTrailLength(); return PaintUtils.interpolate(getBaseColor(), getHighlightColor(), terp); } } return getBaseColor(); }
/** * Selects appropriate color for given frame based on the frame position and gradient difference. * @param i Frame. * @return Frame color. */ private Color calcFrameColor(final int i) { if (frame == -1) { return getBaseColor(); } for (int t = 0; t < getTrailLength(); t++) { if (direction == Direction.RIGHT && i == (frame - t + getPoints()) % getPoints()) { float terp = 1 - ((float) (getTrailLength() - t)) / (float) getTrailLength(); return ColorUtil.interpolate(getBaseColor(), getHighlightColor(), terp); } else if (direction == Direction.LEFT && i == (frame + t) % getPoints()) { float terp = ((float) (t)) / (float) getTrailLength(); return ColorUtil.interpolate(getBaseColor(), getHighlightColor(), terp); } } return getBaseColor(); }
@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)); } }