|
JClass DesktopViews 6.3.0 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.klg.jclass.swing.gauge.GaugeUtil
This class contains common methods for performing linear transformations.
Constructor Summary | |
GaugeUtil()
|
Method Summary | |
static double |
angleToValue(double angle,
double startValue,
double stopValue,
double startAngle,
double stopAngle)
Given an angle, returns the closest circular scale value. |
static double |
arcAngle(double startAngle,
double stopAngle)
Java uses the notion of startAngle and arcAngle
to draw arcs, so this method returns the arcAngle from
startAngle and stopAngle . |
static double |
clamp(double value,
double min,
double max)
Clamp value between min and max |
static void |
createLegendPopulatorRenderer(com.klg.jclass.swing.gauge.JCGauge gauge,
com.klg.jclass.swing.gauge.JCScale scale)
Creates a LegendPopulatorRenderer for a given gauge and scale. |
static double |
distanceBetweenAngles(double a1,
double a2)
Returns the difference of two angles. |
static void |
drawCircleForCircularScale(Graphics g,
com.klg.jclass.swing.gauge.JCCircularScale cscale,
Color foreground,
double value,
double inner_extent,
double outer_extent)
Draws a filled circle based on a circular scale based on the value, inner_extent, and outer_extent. |
static void |
drawCircleForLinearScale(Graphics g,
com.klg.jclass.swing.gauge.JCLinearScale lscale,
Color foreground,
double value,
double inner_extent,
double outer_extent)
Draws a filled circle based on a linear scale based on the value, inner_extent, and outer_extent. |
static void |
drawCircularPolygon(Graphics g,
com.klg.jclass.swing.gauge.JCCircularScale cscale,
Color foreground,
double inner_extent,
double outer_extent,
double width,
double value,
boolean is_reversed,
boolean polygonIsCentered,
com.klg.jclass.swing.gauge.JCPolygon polygon)
Draw a polygon given a circular scale, inner and outer extent, its width, a value on the scale at which to draw, and various other attributes. |
static void |
drawLinearPolygon(Graphics g,
com.klg.jclass.swing.gauge.JCLinearScale lscale,
Color foreground,
double inner_extent,
double outer_extent,
double width,
double value,
boolean is_reversed,
boolean polygonIsCentered,
com.klg.jclass.swing.gauge.JCPolygon polygon)
Draw a polygon given a linear scale, inner and outer extent, its width, a value on the scale at which to draw, and various other attributes. |
static double |
fromRadians(double radians)
Converts radians to degrees. |
static int[] |
getCircleForCircularScale(com.klg.jclass.swing.gauge.JCCircularScale cscale,
double value,
double inner_extent,
double outer_extent)
Get a circle based on a circular scale based on the value, inner_extent, and outer_extent. |
static int[] |
getCircleForLinearScale(com.klg.jclass.swing.gauge.JCLinearScale lscale,
double value,
double inner_extent,
double outer_extent,
Rectangle bounds)
Get the center position and the radius of a circle based on a linear scale based on the value, inner_extent, and outer_extent. |
static Polygon |
getCircularPolygon(com.klg.jclass.swing.gauge.JCCircularScale cscale,
double inner_extent,
double outer_extent,
double width,
double value,
boolean is_reversed,
boolean polygonIsCentered,
com.klg.jclass.swing.gauge.JCPolygon polygon)
Get a polygon position and contour given a circular scale, inner and outer extent, its width, a value on the scale at which to draw, and various other attributes. |
static Polygon |
getLinearPolygon(com.klg.jclass.swing.gauge.JCLinearScale lscale,
double inner_extent,
double outer_extent,
double width,
double value,
boolean is_reversed,
boolean polygonIsCentered,
com.klg.jclass.swing.gauge.JCPolygon polygon,
Rectangle bounds)
Get the contour of a polygon and its position given a linear scale, inner and outer extent, its width, a value on the scale at which to draw, and various other attributes.The xpoints[0], ypoints[0] from Polygon return the position of polygon. |
static double |
normalizeAngle(double angle)
Returns the angle between 0° and 360° corresponding to the inputted angle |
static double |
pointToAngle(double x,
double y,
double x_orig,
double y_orig)
Returns an angle given a point and the origin. |
static double |
positionToValue(int pos,
double startValue,
double stopValue,
int startPos,
int stopPos)
Given a position, returns the closest linear scale value. |
static Polygon |
rotate(Polygon p,
double degrees)
2D rotation of points. |
static Polygon |
scale(Polygon p,
double xAmount,
double yAmount)
Scales an object. |
static double |
toRadians(double degrees)
Converts degrees to radians. |
static Polygon |
translate(Polygon p,
int xamount,
int yamount)
Translate a 2D polygon. |
static Polygon |
translateContour(Polygon input)
|
static double |
valueToAngle(double value,
double start_value,
double stop_value,
double start_angle,
double stop_angle)
Converts a double value to an angle in degrees. |
static int |
valueToPosition(double value,
double start_value,
double stop_value,
int start_pos,
int stop_pos)
Converts a double value to an position in pixels. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GaugeUtil()
Method Detail |
public static double clamp(double value, double min, double max)
value
- The value to be clampedmin
- The min the value can bemax
- The max the value can be
public static double valueToAngle(double value, double start_value, double stop_value, double start_angle, double stop_angle)
value
- The value to be transformedstart_value
- The start value of the circular rangestop_value
- The stop value of the circular rangestart_angle
- The start angle of the circular rangestop_angle
- The stop angle of the circular rangepublic static int valueToPosition(double value, double start_value, double stop_value, int start_pos, int stop_pos)
value
- The value to be transformedstart_value
- The start value of the linear rangestop_value
- The stop value of the linear rangestart_pos
- The start angle of the linear rangestop_pos
- The stop angle of the linear rangepublic static double pointToAngle(double x, double y, double x_orig, double y_orig)
x
- The x-coordinate of the pointy
- The y-coordinate of the pointx_orig
- The x-coordinate of the originy_orig
- The x-coordinate of the originpublic static double angleToValue(double angle, double startValue, double stopValue, double startAngle, double stopAngle)
angle
- An anglestartValue
- The circular scale's start valuestopValue
- The circular scale's stop valuestartAngle
- The circular scale's start anglestopAngle
- The circular scale's stop angle
public static double positionToValue(int pos, double startValue, double stopValue, int startPos, int stopPos)
pos
- A positionstartValue
- The linear scale's start valuestopValue
- The liner scale's stop valuestartPos
- The linear scale's starting positionstopPos
- The linear scale's stoping position
public static double distanceBetweenAngles(double a1, double a2)
a1
- An anglea2
- An angle
public static double arcAngle(double startAngle, double stopAngle)
startAngle
and arcAngle
to draw arcs, so this method returns the arcAngle
from
startAngle
and stopAngle
.
startAngle
- stopAngle
- public static double normalizeAngle(double angle)
angle
- Any angle
public static double toRadians(double degrees)
degrees
-
public static double fromRadians(double radians)
radians
- The radians to be converted to degrees
public static Polygon scale(Polygon p, double xAmount, double yAmount)
p
- the input polygonxAmount
- the amount by which the width is to be scaledyAmount
- the amount by which the height is to be scaled
public static Polygon rotate(Polygon p, double degrees)
p
- The input polygondegrees
- The number of degrees to rotate this polygon
public static Polygon translate(Polygon p, int xamount, int yamount)
p
- The input polygonxamount
- The amount by which the polygon will be shifted
horizontallyyamount
- The amount by which the polygon will be shifted vertically
public static Polygon getCircularPolygon(com.klg.jclass.swing.gauge.JCCircularScale cscale, double inner_extent, double outer_extent, double width, double value, boolean is_reversed, boolean polygonIsCentered, com.klg.jclass.swing.gauge.JCPolygon polygon)
cscale
- The circular scale used to base the polygon drawing oninner_extent
- The inner extent of the polygon (based on the radius
radius of the circular scale).outer_extent
- The outer extent of the polygon (based on the radius
radius of the circular scale).width
- The width of the polygon (in pixels)value
- The value along the scale at which to draw (it must be
between the scale's min and max)is_reversed
- Is the polygon reversed?polygonIsCentered
- If the polygon is centered, place it midway between
the inner and outer extent. Otherwise, place the
polygon origin at left extent.polygon
- The polygon to draw. The JCPolygon class is a class that
extends Polygon. It contains a method to get a bounding
rectangle around a polygon.
public static void drawCircularPolygon(Graphics g, com.klg.jclass.swing.gauge.JCCircularScale cscale, Color foreground, double inner_extent, double outer_extent, double width, double value, boolean is_reversed, boolean polygonIsCentered, com.klg.jclass.swing.gauge.JCPolygon polygon)
g
- The graphics context on which to drawcscale
- The circular scale used to base the polygon drawing onforeground
- The foreground color of the polygoninner_extent
- The inner extent of the polygon (based on the radius
radius of the circular scale).outer_extent
- The outer extent of the polygon (based on the radius
radius of the circular scale).width
- The width of the polygon (in pixels)value
- The value along the scale at which to draw (it must be
between the scale's min and max)is_reversed
- Is the polygon reversed?polygonIsCentered
- If the polygon is centered, place it midway between
the inner and outer extent. Otherwise, place the
polygon origin at left extent.polygon
- The polygon to draw. The JCPolygon class is a class that
extends Polygon. It contains a method to get a bounding
rectangle around a polygon.public static Polygon getLinearPolygon(com.klg.jclass.swing.gauge.JCLinearScale lscale, double inner_extent, double outer_extent, double width, double value, boolean is_reversed, boolean polygonIsCentered, com.klg.jclass.swing.gauge.JCPolygon polygon, Rectangle bounds)
lscale
- The linear scale used to base the polygon drawing oninner_extent
- The inner extent of the polygon (based on the radius
radius of the circular scale).outer_extent
- The outer extent of the polygon (based on the radius
radius of the circular scale).width
- The width of the polygon (in pixels)value
- The value along the scale at which to draw (it must be
between the scale's min and max)is_reversed
- Is the polygon reversed?polygonIsCentered
- If the polygon is centered, place it midway between
the inner and outer extent. Otherwise, place the
polygon origin at left extent.polygon
- The polygon to draw. The JCPolygon class is a class that
extends Polygon. It contains a method to get a bounding
rectangle around a polygon.bounds
- The reference rectangle for contour. For drawing used
lscale.getScaleSize(). For image mapping use lscale.getBounds()
public static void drawLinearPolygon(Graphics g, com.klg.jclass.swing.gauge.JCLinearScale lscale, Color foreground, double inner_extent, double outer_extent, double width, double value, boolean is_reversed, boolean polygonIsCentered, com.klg.jclass.swing.gauge.JCPolygon polygon)
g
- The graphics context on which to drawlscale
- The linear scale used to base the polygon drawing onforeground
- The foreground color of the polygoninner_extent
- The inner extent of the polygon (based on the radius
radius of the circular scale).outer_extent
- The outer extent of the polygon (based on the radius
radius of the circular scale).width
- The width of the polygon (in pixels)value
- The value along the scale at which to draw (it must be
between the scale's min and max)is_reversed
- Is the polygon reversed?polygonIsCentered
- If the polygon is centered, place it midway between
the inner and outer extent. Otherwise, place the
polygon origin at left extent.polygon
- The polygon to draw. The JCPolygon class is a class that
extends Polygon. It contains a method to get a bounding
rectangle around a polygon.public static int[] getCircleForCircularScale(com.klg.jclass.swing.gauge.JCCircularScale cscale, double value, double inner_extent, double outer_extent)
cscale
- The circular scale used to determine radius & positionvalue
- The value on the scale at which this circle will be drawninner_extent
- The inner extent as a fraction of the radiusouter_extent
- The outer extent as a fraction of the radius
public static void drawCircleForCircularScale(Graphics g, com.klg.jclass.swing.gauge.JCCircularScale cscale, Color foreground, double value, double inner_extent, double outer_extent)
g
- The graphics context on which to drawcscale
- The circular scale used to determine radius & positionforeground
- The foreground color of the circlevalue
- The value on the scale at which this circle will be drawninner_extent
- The inner extent as a fraction of the radiusouter_extent
- The outer extent as a fraction of the radiuspublic static int[] getCircleForLinearScale(com.klg.jclass.swing.gauge.JCLinearScale lscale, double value, double inner_extent, double outer_extent, Rectangle bounds)
lscale
- The linear scale used to determine radius & positionvalue
- The value on the scale at which this circle will be drawninner_extent
- The inner extent as a fraction of the radiusouter_extent
- The outer extent as a fraction of the radiusbounds
- Rectangle The reference rectangle for contour. For drawing used
lscale.getScaleSize(). For image mapping use lscale.getBounds()
public static void drawCircleForLinearScale(Graphics g, com.klg.jclass.swing.gauge.JCLinearScale lscale, Color foreground, double value, double inner_extent, double outer_extent)
g
- The graphics context on which to drawlscale
- The linear scale used to determine position and width/heightforeground
- The foreground color of the circlevalue
- The value on the scale at which this circle will be drawninner_extent
- The inner extent as a fraction of the width/heightouter_extent
- The outer extent as a fraction of the width/heightpublic static void createLegendPopulatorRenderer(com.klg.jclass.swing.gauge.JCGauge gauge, com.klg.jclass.swing.gauge.JCScale scale)
gauge
- The gauge whose legend needs a PopulatorRendererscale
- The scale whose ranges need to be part of a legend.public static Polygon translateContour(Polygon input)
input
- Polygon to be translated
|
Copyright © 2004 Quest Software Inc.. All rights reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |