eu.hansolo.steelseries.extras.WindDirection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SteelSeries Show documentation
Show all versions of SteelSeries Show documentation
The SteelSeries is a javabeans component library that contains gauges.
You will find linear and radial gauges. In addition you will also find
digital displays, indicators from cars and some instruments from airplanes and
sailboats.
package eu.hansolo.steelseries.extras;
/**
*
* @author hansolo
*/
public class WindDirection extends eu.hansolo.steelseries.gauges.AbstractRadial
{
private double visibleValue = 0;
private double angleStep;
//private java.awt.Font font = new java.awt.Font("Verdana", 0, 30);
private final java.awt.geom.Point2D CENTER = new java.awt.geom.Point2D.Double();
private final java.awt.geom.Point2D LCD_POSITION = new java.awt.geom.Point2D.Double();
private final java.awt.GraphicsConfiguration GFX_CONF = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
private java.awt.image.BufferedImage frameImage;
private java.awt.image.BufferedImage backgroundImage;
private java.awt.image.BufferedImage shipImage;
private java.awt.image.BufferedImage titleImage;
private java.awt.image.BufferedImage tickmarksImage;
private java.awt.image.BufferedImage lcdImage;
private java.awt.image.BufferedImage pointerImage;
private java.awt.image.BufferedImage pointer2Image;
private java.awt.image.BufferedImage foregroundImage;
private java.awt.image.BufferedImage disabledImage;
private eu.hansolo.steelseries.tools.ColorDef pointer2Color = eu.hansolo.steelseries.tools.ColorDef.BLUE;
private eu.hansolo.steelseries.tools.CustomColorDef customPointer2Color = new eu.hansolo.steelseries.tools.CustomColorDef(java.awt.Color.BLUE);
private eu.hansolo.steelseries.tools.PointerType pointer2Type = eu.hansolo.steelseries.tools.PointerType.TYPE3;
private boolean pointer2Visible;
private double value2;
private final org.pushingpixels.trident.Timeline TIMELINE = new org.pushingpixels.trident.Timeline(this);
private final org.pushingpixels.trident.ease.Spline EASE = new org.pushingpixels.trident.ease.Spline(0.5f);
private long easingDuration = 250;
private final java.awt.font.FontRenderContext RENDER_CONTEXT = new java.awt.font.FontRenderContext(null, true, true);
private java.awt.font.TextLayout unitLayout;
private final java.awt.geom.Rectangle2D UNIT_BOUNDARY = new java.awt.geom.Rectangle2D.Double();
private java.awt.font.TextLayout valueLayout;
private final java.awt.geom.Rectangle2D VALUE_BOUNDARY = new java.awt.geom.Rectangle2D.Double();
public WindDirection()
{
super();
setMinValue(-360);
setMaxValue(360);
setPointerType(eu.hansolo.steelseries.tools.PointerType.TYPE5);
setLcdColor(eu.hansolo.steelseries.tools.LcdColor.BLACK_LCD);
setValueCoupled(false);
setLcdDecimals(1);
setLcdVisible(true);
calcAngleStep();
value2 = 0;
pointer2Visible = true;
init(getInnerBounds().width, getInnerBounds().height);
}
@Override
public final eu.hansolo.steelseries.gauges.AbstractGauge init(int WIDTH, int HEIGHT)
{
if (isDigitalFont())
{
setLcdValueFont(LCD_DIGITAL_FONT.deriveFont(0.7f * WIDTH * 0.15f));
}
else
{
setLcdValueFont(LCD_STANDARD_FONT.deriveFont(0.625f * WIDTH * 0.15f));
}
if (getUseCustomLcdUnitFont())
{
setLcdUnitFont(getCustomLcdUnitFont().deriveFont(0.25f * WIDTH * 0.15f));
}
else
{
setLcdUnitFont(LCD_STANDARD_FONT.deriveFont(0.25f * WIDTH * 0.15f));
}
if (frameImage != null)
{
frameImage.flush();
}
frameImage = create_FRAME_Image(WIDTH);
if (backgroundImage != null)
{
backgroundImage.flush();
}
backgroundImage = create_BACKGROUND_Image(WIDTH);
if (shipImage != null)
{
shipImage.flush();
}
shipImage = create_SHIP_Image(WIDTH);
if (titleImage != null)
{
titleImage.flush();
}
titleImage = create_TITLE_Image(WIDTH, getTitle(), getUnitString());
if (tickmarksImage != null)
{
tickmarksImage.flush();
}
tickmarksImage = create_TICKMARKS_Image(WIDTH, 0, 0, 0, 0, 0, 0, 0, true, true, null);
if (lcdImage != null)
{
lcdImage.flush();
}
//lcdImage = create_LCD_Image((int) (WIDTH * 0.55), (int) (WIDTH * 0.15), getLcdColor(), getCustomLcdBackground());
lcdImage = create_LCD_Image((int) (WIDTH * 0.4), (int) (WIDTH * 0.15), getLcdColor(), getCustomLcdBackground());
LCD_POSITION.setLocation(((getGaugeBounds().width - lcdImage.getWidth()) / 2.0), (getGaugeBounds().height * 0.55));
if (pointerImage != null)
{
pointerImage.flush();
}
pointerImage = create_POINTER_Image(WIDTH, getPointerType());
if (pointer2Image != null)
{
pointer2Image.flush();
}
pointer2Image = create_POINTER_Image(WIDTH, pointer2Type, pointer2Color, customPointer2Color);
if (foregroundImage != null)
{
foregroundImage.flush();
}
foregroundImage = create_FOREGROUND_Image(WIDTH, true, getForegroundType());
if (disabledImage != null)
{
disabledImage.flush();
}
disabledImage = create_DISABLED_Image(WIDTH);
//font = new java.awt.Font("Verdana", 0, (int) (0.15 * getWidth()));
// Create sections if not empty
if (!getSections().isEmpty())
{
createSections();
}
return this;
}
@Override
protected void paintComponent(java.awt.Graphics g)
{
if (!isInitialized())
{
return;
}
final java.awt.Graphics2D G2 = (java.awt.Graphics2D) g.create();
G2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
G2.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING, java.awt.RenderingHints.VALUE_RENDER_QUALITY);
//G2.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING, java.awt.RenderingHints.VALUE_DITHER_ENABLE);
//G2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
//G2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);
G2.setRenderingHint(java.awt.RenderingHints.KEY_STROKE_CONTROL, java.awt.RenderingHints.VALUE_STROKE_PURE);
G2.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
// Translate the coordinate system related to insets
G2.translate(getInnerBounds().x, getInnerBounds().y);
CENTER.setLocation(getGaugeBounds().getCenterX(), getGaugeBounds().getCenterX());
// Draw the frame
if (isFrameVisible())
{
G2.drawImage(frameImage, 0, 0, null);
}
// Draw the background
if (isBackgroundVisible())
{
G2.drawImage(backgroundImage, 0, 0, null);
G2.drawImage(shipImage, 0, 0, null);
}
// Draw title and unit
G2.drawImage(titleImage, 0, 0, null);
// Draw the sections
if (isSectionsVisible())
{
for (eu.hansolo.steelseries.tools.Section section : getSections())
{
G2.setColor(section.getColor());
G2.fill(section.getSectionArea());
}
}
// Draw the tickmarks
G2.drawImage(tickmarksImage, 0, 0, null);
// Draw LCD display
if (isLcdVisible())
{
//G2.drawImage(lcdImage, (int) ((getGaugeBounds().width - lcdImage.getWidth()) / 2.0), (int) (getGaugeBounds().height * 0.55), null);
G2.drawImage(lcdImage, (int) (LCD_POSITION.getX()), (int) (LCD_POSITION.getY()), null);
if (getLcdColor() == eu.hansolo.steelseries.tools.LcdColor.CUSTOM)
{
G2.setColor(getCustomLcdForeground());
}
else
{
G2.setColor(getLcdColor().TEXT_COLOR);
}
G2.setFont(getLcdUnitFont());
final double UNIT_STRING_WIDTH;
if (isLcdUnitStringVisible())
{
unitLayout = new java.awt.font.TextLayout(getLcdUnitString(), G2.getFont(), RENDER_CONTEXT);
UNIT_BOUNDARY.setFrame(unitLayout.getBounds());
G2.drawString(getLcdUnitString(), (int) (LCD_POSITION.getX() + (lcdImage.getWidth() - UNIT_BOUNDARY.getWidth()) - lcdImage.getWidth() * 0.03), (int) (LCD_POSITION.getY() + lcdImage.getHeight() * 0.76f));
UNIT_STRING_WIDTH = UNIT_BOUNDARY.getWidth();
}
else
{
UNIT_STRING_WIDTH = 0;
}
G2.setFont(getLcdValueFont());
valueLayout = new java.awt.font.TextLayout(formatLcdValue(getLcdValue()), G2.getFont(), RENDER_CONTEXT);
VALUE_BOUNDARY.setFrame(valueLayout.getBounds());
G2.drawString(formatLcdValue(getLcdValue()), (int) (LCD_POSITION.getX() + (lcdImage.getWidth() - UNIT_STRING_WIDTH - VALUE_BOUNDARY.getWidth()) - lcdImage.getWidth() * 0.09), (int) (LCD_POSITION.getY() + lcdImage.getHeight() * 0.76f));
}
// Draw the pointer2
final java.awt.geom.AffineTransform OLD_TRANSFORM = G2.getTransform();
G2.rotate(value2 * angleStep, CENTER.getX(), CENTER.getY());
G2.drawImage(pointer2Image, 0, 0, null);
G2.setTransform(OLD_TRANSFORM);
// Draw the pointer
G2.rotate(getValue() * angleStep, CENTER.getX(), CENTER.getY());
G2.drawImage(pointerImage, 0, 0, null);
G2.setTransform(OLD_TRANSFORM);
// Draw the foreground
if (isForegroundVisible())
{
G2.drawImage(foregroundImage, 0, 0, null);
}
if (!isEnabled())
{
G2.drawImage(disabledImage, 0, 0, null);
}
// Translate the coordinate system back to original
G2.translate(-getInnerBounds().x, -getInnerBounds().y);
G2.dispose();
}
@Override
public void setValue(final double VALUE)
{
if (isEnabled())
{
super.setValue((VALUE % 360));
if ((VALUE % 360) == 0)
{
this.visibleValue = 90;
}
if ((VALUE % 360) > 0 && (VALUE % 360) <= 180)
{
this.visibleValue = ((VALUE % 360));
}
if ((VALUE % 360) > 180 && (VALUE % 360) <= 360)
{
this.visibleValue = (360 - (VALUE % 360));
}
if (isValueCoupled())
{
setLcdValue(visibleValue);
}
fireStateChanged();
repaint(getInnerBounds());
}
}
@Override
public void setValueAnimated(double value)
{
if (isEnabled())
{
if (TIMELINE.getState() == org.pushingpixels.trident.Timeline.TimelineState.PLAYING_FORWARD || TIMELINE.getState() == org.pushingpixels.trident.Timeline.TimelineState.PLAYING_REVERSE)
{
TIMELINE.abort();
}
TIMELINE.addPropertyToInterpolate("value", getValue(), value);
TIMELINE.setEase(EASE);
TIMELINE.setDuration(easingDuration);
TIMELINE.play();
}
}
@Override
public double getMinValue()
{
return -360.0;
}
@Override
public double getMaxValue()
{
return 360.0;
}
public long getEasingDuration()
{
return this.easingDuration;
}
public void setEasingDuration(final long EASING_DURATION)
{
this.easingDuration = EASING_DURATION;
}
/**
* Returns the colordefinition of the second pointer
* @return the colordefinition of the second pointer
*/
public eu.hansolo.steelseries.tools.ColorDef getPointer2Color()
{
return pointer2Color;
}
/**
* Sets the colordefinition of the second pointer
* @param POINTER2_COLOR
*/
public void setPointer2Color(final eu.hansolo.steelseries.tools.ColorDef POINTER2_COLOR)
{
pointer2Color = POINTER2_COLOR;
init(getInnerBounds().width, getInnerBounds().height);
repaint(getInnerBounds());
}
/**
* Returns the value of the second pointer
* @return the value of the second pointer
*/
public double getValue2()
{
return value2;
}
/**
* Sets the value of the second pointer
* @param VALUE2
*/
public void setValue2(final double VALUE2)
{
if (isEnabled())
{
value2 = (VALUE2 % 360);
fireStateChanged();
repaint(getInnerBounds());
}
}
/**
* Returns true if the second pointer is visible
* @return true if the second pointer is visible
*/
public boolean isPointer2Visible()
{
return pointer2Visible;
}
/**
* Enables / disables the visibility of the second pointer
* @param POINTER2_VISIBLE
*/
public void setPointer2Visible(final boolean POINTER2_VISIBLE)
{
pointer2Visible = POINTER2_VISIBLE;
repaint(getInnerBounds());
}
/**
* Returns the pointertype of the second pointer
* @return the pointertype of the second pointer
*/
public eu.hansolo.steelseries.tools.PointerType getPointer2Type()
{
return pointer2Type;
}
/**
* Sets the pointertype of the second pointer
* @param POINTER2_TYPE
*/
public void setPointer2Type(final eu.hansolo.steelseries.tools.PointerType POINTER2_TYPE)
{
pointer2Type = POINTER2_TYPE;
init(getInnerBounds().width, getInnerBounds().height);
repaint(getInnerBounds());
}
/**
* Returns the color from which the custom pointer2 color will be calculated
* @return the color from which the custom pointer2 color will be calculated
*/
public java.awt.Color getCustomPointer2Color()
{
return this.customPointer2Color.COLOR;
}
/**
* Sets the color from which the custom pointer2 color is calculated
* @param COLOR
*/
public void setCustomPointer2Color(final java.awt.Color COLOR)
{
this.customPointer2Color = new eu.hansolo.steelseries.tools.CustomColorDef(COLOR);
init(getInnerBounds().width, getInnerBounds().height);
repaint(getInnerBounds());
}
/**
* Returns the object that represents the custom pointer2 color
* @return the object that represents the custom pointer2 color
*/
public eu.hansolo.steelseries.tools.CustomColorDef getCustomPointer2ColorObject()
{
return this.customPointer2Color;
}
private void calcAngleStep()
{
angleStep = (2.0 * Math.PI) / 360.0;
}
@Override
public java.awt.geom.Point2D getCenter()
{
return new java.awt.geom.Point2D.Double(backgroundImage.getWidth() / 2.0 + getInnerBounds().x, backgroundImage.getHeight() / 2.0 + getInnerBounds().y);
}
@Override
public java.awt.geom.Rectangle2D getBounds2D()
{
return new java.awt.geom.Rectangle2D.Double(backgroundImage.getMinX(), backgroundImage.getMinY(), backgroundImage.getWidth(), backgroundImage.getHeight());
}
private void createSections()
{
final double ORIGIN_CORRECTION;
final double ANGLE_STEP;
final double OUTER_RADIUS;
final double INNER_RADIUS;
final double FREE_AREA_OUTER_RADIUS;
final double FREE_AREA_INNER_RADIUS;
final java.awt.geom.Ellipse2D INNER;
if (backgroundImage != null)
{
ORIGIN_CORRECTION = 90.0;
ANGLE_STEP = 1.0;
OUTER_RADIUS = backgroundImage.getWidth() * 0.38f;
INNER_RADIUS = backgroundImage.getWidth() * 0.38f - backgroundImage.getWidth() * 0.04f;
FREE_AREA_OUTER_RADIUS = backgroundImage.getWidth() / 2.0 - OUTER_RADIUS;
FREE_AREA_INNER_RADIUS = backgroundImage.getWidth() / 2.0 - INNER_RADIUS;
INNER = new java.awt.geom.Ellipse2D.Double(backgroundImage.getMinX() + FREE_AREA_INNER_RADIUS, backgroundImage.getMinY() + FREE_AREA_INNER_RADIUS, 2 * INNER_RADIUS, 2 * INNER_RADIUS);
for (eu.hansolo.steelseries.tools.Section section : getSections())
{
final double ANGLE_START = ORIGIN_CORRECTION - (section.getStart() * ANGLE_STEP) + (getMinValue() * ANGLE_STEP);
final double ANGLE_EXTEND = -(section.getStop() - section.getStart()) * ANGLE_STEP;
final java.awt.geom.Arc2D OUTER_ARC = new java.awt.geom.Arc2D.Double(java.awt.geom.Arc2D.PIE);
OUTER_ARC.setFrame(backgroundImage.getMinX() + FREE_AREA_OUTER_RADIUS, backgroundImage.getMinY() + FREE_AREA_OUTER_RADIUS, 2 * OUTER_RADIUS, 2 * OUTER_RADIUS);
OUTER_ARC.setAngleStart(ANGLE_START);
OUTER_ARC.setAngleExtent(ANGLE_EXTEND);
final java.awt.geom.Area SECTION = new java.awt.geom.Area(OUTER_ARC);
SECTION.subtract(new java.awt.geom.Area(INNER));
section.setSectionArea(SECTION);
}
}
}
@Override
protected java.awt.image.BufferedImage create_TICKMARKS_Image(final int WIDTH, final double FREE_AREA_ANGLE, final double OFFSET, final double MIN_VALUE, final double MAX_VALUE, final double ANGLE_STEP, final int TICK_LABEL_PERIOD, final int SCALE_DIVIDER_POWER, final boolean DRAW_TICKS, final boolean DRAW_TICK_LABELS, final java.util.ArrayList TICKMARK_SECTIONS)
{
if (WIDTH <= 0)
{
return null;
}
final java.awt.image.BufferedImage IMAGE = GFX_CONF.createCompatibleImage(WIDTH, (int) (1.0 * WIDTH), java.awt.Transparency.TRANSLUCENT);
final java.awt.Graphics2D G2 = IMAGE.createGraphics();
G2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
G2.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING, java.awt.RenderingHints.VALUE_RENDER_QUALITY);
G2.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING, java.awt.RenderingHints.VALUE_DITHER_ENABLE);
G2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
G2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);
G2.setRenderingHint(java.awt.RenderingHints.KEY_STROKE_CONTROL, java.awt.RenderingHints.VALUE_STROKE_PURE);
G2.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
final int IMAGE_WIDTH = IMAGE.getWidth();
final int IMAGE_HEIGHT = IMAGE.getHeight();
final java.awt.Font STD_FONT = new java.awt.Font("Verdana", 0, (int) (0.04 * WIDTH));
final java.awt.BasicStroke MEDIUM_STROKE = new java.awt.BasicStroke(1.0f, java.awt.BasicStroke.CAP_ROUND, java.awt.BasicStroke.JOIN_BEVEL);
final java.awt.BasicStroke THIN_STROKE = new java.awt.BasicStroke(0.5f, java.awt.BasicStroke.CAP_ROUND, java.awt.BasicStroke.JOIN_BEVEL);
final int TEXT_DISTANCE = (int) (0.08 * WIDTH);
//final int MIN_LENGTH = (int) (0.0133333333 * WIDTH);
final int MED_LENGTH = (int) (0.02 * WIDTH);
final int MAX_LENGTH = (int) (0.04 * WIDTH);
//final int MIN_DIAMETER = (int) (0.0093457944 * WIDTH);
final int MED_DIAMETER = (int) (0.0186915888 * WIDTH);
final int MAX_DIAMETER = (int) (0.0280373832 * WIDTH);
// Create the ticks itself
final float RADIUS = IMAGE_WIDTH * 0.38f;
final java.awt.geom.Point2D GAUGE_CENTER = new java.awt.geom.Point2D.Double(IMAGE_WIDTH / 2.0f, IMAGE_HEIGHT / 2.0f);
// Draw ticks
java.awt.geom.Point2D innerPoint;
java.awt.geom.Point2D outerPoint;
java.awt.geom.Point2D textPoint = null;
java.awt.Shape tick;
int counter = 0;
int tickCounter = 0;
float valueCounter = 90;
boolean countUp = false;
float valueStep = 1;
G2.setFont(STD_FONT);
double sinValue = 0;
double cosValue = 0;
final double STEP = (2.0 * Math.PI) / (360.0);
for (double alpha = (2.0 * Math.PI) ; alpha >= STEP; alpha -= STEP)
{
G2.setStroke(THIN_STROKE);
sinValue = Math.sin(alpha - Math.PI / 2);
cosValue = Math.cos(alpha - Math.PI / 2);
// Different tickmark every 5 units
if (counter % 5 == 0)
{
G2.setColor(super.getBackgroundColor().LABEL_COLOR);
G2.setStroke(THIN_STROKE);
innerPoint = new java.awt.geom.Point2D.Double(GAUGE_CENTER.getX() + (RADIUS - MED_LENGTH) * sinValue, GAUGE_CENTER.getY() + (RADIUS - MED_LENGTH) * cosValue);
outerPoint = new java.awt.geom.Point2D.Double(GAUGE_CENTER.getX() + RADIUS * sinValue, GAUGE_CENTER.getY() + RADIUS * cosValue);
// Draw ticks
switch(getMinorTickmarkType())
{
case LINE:
tick = new java.awt.geom.Line2D.Double(innerPoint.getX(), innerPoint.getY(), outerPoint.getX(), outerPoint.getY());
G2.draw(tick);
break;
case CIRCLE:
tick = new java.awt.geom.Ellipse2D.Double(outerPoint.getX() - MED_DIAMETER / 2.0, outerPoint.getY() - MED_DIAMETER / 2.0, MED_DIAMETER, MED_DIAMETER);
G2.fill(tick);
break;
// case TRIANGLE:
//
// break;
// case SQUARE:
// tick = new java.awt.geom.Rectangle2D.Double(outerPoint.getX() - MED_DIAMETER / 2.0, outerPoint.getY() - MED_DIAMETER / 2.0, MED_DIAMETER, MED_DIAMETER);
// G2.fill(tick);
// break;
default:
tick = new java.awt.geom.Line2D.Double(innerPoint.getX(), innerPoint.getY(), outerPoint.getX(), outerPoint.getY());
G2.draw(tick);
break;
}
}
// Different tickmark every 45 units plus text
if (counter == 30 || counter == 0)
{
G2.setColor(super.getBackgroundColor().LABEL_COLOR);
G2.setStroke(MEDIUM_STROKE);
innerPoint = new java.awt.geom.Point2D.Double(GAUGE_CENTER.getX() + (RADIUS - MAX_LENGTH) * sinValue, GAUGE_CENTER.getY() + (RADIUS - MAX_LENGTH) * cosValue);
outerPoint = new java.awt.geom.Point2D.Double(GAUGE_CENTER.getX() + RADIUS * sinValue, GAUGE_CENTER.getY() + RADIUS * cosValue);
// Draw outer text
textPoint = new java.awt.geom.Point2D.Double(GAUGE_CENTER.getX() + (RADIUS - TEXT_DISTANCE) * sinValue, GAUGE_CENTER.getY() + (RADIUS - TEXT_DISTANCE) * cosValue);
G2.setFont(STD_FONT);
//G2.fill(UTIL.rotateTextAroundCenter(G2, String.valueOf((int) valueCounter), (int) textPoint.getX(), (int) textPoint.getY(), Math.toDegrees(Math.PI - alpha)));
G2.fill(UTIL.rotateTextAroundCenter(G2, String.valueOf((int) valueCounter), (int) textPoint.getX(), (int) textPoint.getY(), Math.toDegrees(0)));
counter = 0;
tickCounter++;
// Draw ticks
switch(getMinorTickmarkType())
{
case LINE:
tick = new java.awt.geom.Line2D.Double(innerPoint.getX(), innerPoint.getY(), outerPoint.getX(), outerPoint.getY());
G2.draw(tick);
break;
case CIRCLE:
tick = new java.awt.geom.Ellipse2D.Double(outerPoint.getX() - MAX_DIAMETER / 2.0, outerPoint.getY() - MAX_DIAMETER / 2.0, MAX_DIAMETER, MAX_DIAMETER);
G2.fill(tick);
break;
//case TRIANGLE:
// break;
case SQUARE:
tick = new java.awt.geom.Rectangle2D.Double(outerPoint.getX() - MAX_DIAMETER / 2.0, outerPoint.getY() - MAX_DIAMETER / 2.0, MAX_DIAMETER, MAX_DIAMETER);
G2.fill(tick);
break;
default:
tick = new java.awt.geom.Line2D.Double(innerPoint.getX(), innerPoint.getY(), outerPoint.getX(), outerPoint.getY());
G2.draw(tick);
break;
}
}
counter++;
if (valueCounter == 0)
{
countUp = true;
}
if (valueCounter == 180)
{
countUp = false;
}
if (countUp)
{
valueCounter += valueStep;
}
else
{
valueCounter -= valueStep;
}
}
G2.dispose();
return IMAGE;
}
private java.awt.image.BufferedImage create_SHIP_Image(final int WIDTH)
{
if (WIDTH <= 0)
{
return GFX_CONF.createCompatibleImage(10, 10, java.awt.Transparency.TRANSLUCENT);
}
final java.awt.image.BufferedImage IMAGE = GFX_CONF.createCompatibleImage(WIDTH, WIDTH, java.awt.Transparency.TRANSLUCENT);
final java.awt.Graphics2D G2 = IMAGE.createGraphics();
G2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
G2.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING, java.awt.RenderingHints.VALUE_RENDER_QUALITY);
G2.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING, java.awt.RenderingHints.VALUE_DITHER_ENABLE);
G2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
G2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);
G2.setRenderingHint(java.awt.RenderingHints.KEY_STROKE_CONTROL, java.awt.RenderingHints.VALUE_STROKE_PURE);
G2.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
final int IMAGE_WIDTH = IMAGE.getWidth();
final int IMAGE_HEIGHT = IMAGE.getHeight();
final java.awt.geom.GeneralPath SHIP = new java.awt.geom.GeneralPath();
SHIP.setWindingRule(java.awt.geom.GeneralPath.WIND_EVEN_ODD);
SHIP.moveTo(IMAGE_WIDTH * 0.4439252336448598, IMAGE_HEIGHT * 0.7242990654205608);
SHIP.curveTo(IMAGE_WIDTH * 0.4439252336448598, IMAGE_HEIGHT * 0.7242990654205608, IMAGE_WIDTH * 0.45794392523364486, IMAGE_HEIGHT * 0.7383177570093458, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.7383177570093458);
SHIP.curveTo(IMAGE_WIDTH * 0.5420560747663551, IMAGE_HEIGHT * 0.7383177570093458, IMAGE_WIDTH * 0.5560747663551402, IMAGE_HEIGHT * 0.7242990654205608, IMAGE_WIDTH * 0.5560747663551402, IMAGE_HEIGHT * 0.7242990654205608);
SHIP.curveTo(IMAGE_WIDTH * 0.5560747663551402, IMAGE_HEIGHT * 0.7242990654205608, IMAGE_WIDTH * 0.5654205607476636, IMAGE_HEIGHT * 0.6962616822429907, IMAGE_WIDTH * 0.5654205607476636, IMAGE_HEIGHT * 0.48598130841121495);
SHIP.curveTo(IMAGE_WIDTH * 0.5654205607476636, IMAGE_HEIGHT * 0.2897196261682243, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.2336448598130841, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.2336448598130841);
SHIP.curveTo(IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.2336448598130841, IMAGE_WIDTH * 0.42990654205607476, IMAGE_HEIGHT * 0.2897196261682243, IMAGE_WIDTH * 0.42990654205607476, IMAGE_HEIGHT * 0.48598130841121495);
SHIP.curveTo(IMAGE_WIDTH * 0.42990654205607476, IMAGE_HEIGHT * 0.719626168224299, IMAGE_WIDTH * 0.4439252336448598, IMAGE_HEIGHT * 0.7242990654205608, IMAGE_WIDTH * 0.4439252336448598, IMAGE_HEIGHT * 0.7242990654205608);
SHIP.closePath();
G2.setColor(getBackgroundColor().LABEL_COLOR);
G2.setStroke(new java.awt.BasicStroke(1.0f, java.awt.BasicStroke.CAP_BUTT, java.awt.BasicStroke.JOIN_MITER));
G2.draw(SHIP);
G2.dispose();
return IMAGE;
}
@Override
public String toString()
{
return "WindDirection";
}
}