The following is the simplest way to create a java gauge. The first step starts with importing the class files into your java project. Firstly, we import the nextwave gauge for java libraries. import com.nextwavesoft.enumeration.*; import com.nextwavesoft.gauge.*; import com.nextwavesoft.primitives.*; import com.nextwavesoft.shared.*; Then, we initialize the java gauge object, in this case we initialize a circular java gauge. CircularGauge circularGauge = new CircularGauge(); circularGauge.setBackground(new Color(44,44,44)); circularGauge.setRimBrush(new Color(44,44,44)); circularGauge.setBackgroundType(CircularBackgroundType.CircularTopGradient); circularGauge.setBackgroundRadiusRatio(0.97); We begin to create a scale bar . Take note that the unit is in percentage . By default, the unit is absolute. Percentage allow gauge to resize when the control resize.
//Create circular scale which holds circular tickset. CircularScale circularScale = new CircularScale(); circularScale.setRadius(new Unit(74,UnitType.Percentage)); circularScale.setBarExtent(new Unit(2,UnitType.Percentage)); circularScale.setStartAngle(135); circularScale.setSweepAngle(270); Then, create circular tickset, which holds the tickSetCollection, pointerCollection and rangeCollection. //Create tickset which holds tick, range, marker and pointer. CircularTickSet circularTickSet = new CircularTickSet(); circularTickSet.setMinimum(0); circularTickSet.setMaximum(50); circularTickSet.setMinorInterval(2); circularTickSet.setMajorInterval(10); Then, continues to create tick mark major , tick mark minor and tick label major. //create tick mark minor CircularTickMarkMinor tickMarkMinor = new CircularTickMarkMinor(); tickMarkMinor.setTickMarkAscent(new Unit(0.5,UnitType.Percentage)); tickMarkMinor.setTickMarkExtent(new Unit(4,UnitType.Percentage)); tickMarkMinor.setBackground(Color.WHITE); tickMarkMinor.setScalePlacement(ScalePlacement.Inside); //create tick mark major CircularTickMarkMajor tickMarkMajor = new CircularTickMarkMajor(); tickMarkMajor.setTickMarkAscent(new Unit(1,UnitType.Percentage)); tickMarkMajor.setTickMarkExtent(new Unit(6,UnitType.Percentage)); tickMarkMajor.setBackground(Color.WHITE); tickMarkMajor.setScalePlacement(ScalePlacement.Inside); //create tick label major CircularTickLabelMajor tickLabelMajor = new CircularTickLabelMajor(); tickLabelMajor.setFontFamily("Verdana"); tickLabelMajor.setFontSize(new Unit(10,UnitType.Percentage)); tickLabelMajor.setForeground(Color.WHITE); tickLabelMajor.setOrientation(TextOrientation.Rotated); tickLabelMajor.setScalePlacement(ScalePlacement.Inside); tickLabelMajor.setScaleOffset(new Unit(5,UnitType.Percentage)); Then,creates a pointer needle and a pointer cap. //create pointer needle CircularPointerNeedle pointerNeedle = new CircularPointerNeedle(); pointerNeedle.setPointerExtent(new Unit(135,UnitType.Percentage)); pointerNeedle.setPointerAscent(new Unit(3,UnitType.Percentage)); pointerNeedle.setBackground(new Color(206,28,28)); pointerNeedle.setNeedleType(PointerNeedleType.PivotSwordSharp); CircularPointerCap pointerCap = new CircularPointerCap(); pointerCap.setPointerExtent(new Unit(25,UnitType.Percentage)); pointerCap.setBackground(new Color(163,28,28)); pointerCap.setCapType(PointerCapType.CircleConvex); Finally, we the gauge element into respective collection. circularTickSet.getCircularPointerCollection().add(pointerCap); circularTickSet.getCircularPointerCollection().add(pointerNeedle); circularTickSet.getCircularTickCollection().add(tickMarkMajor); circularTickSet.getCircularTickCollection().add(tickMarkMinor); circularTickSet.getCircularTickCollection().add(tickLabelMajor); circularScale.getCircularTickSetCollection().add(circularTickSet); circularGauge.getCircularScaleCollection().add(circularScale);
|
|||||||
| < | February 2012 | > | ||||
| Mo | Tu | We | Th | Fr | Sa | Su |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | ||||