package com.nextwavesoft; import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import javax.swing.JFrame; import com.nextwavesoft.enumeration.CircularBackgroundType; import com.nextwavesoft.enumeration.PointerCapType; import com.nextwavesoft.enumeration.PointerNeedleType; import com.nextwavesoft.enumeration.ScalePlacement; import com.nextwavesoft.enumeration.TextOrientation; import com.nextwavesoft.enumeration.UnitType; import com.nextwavesoft.gauge.*; import com.nextwavesoft.shared.Unit; public class GettingStarted { public static void main(String[] argv) { GettingStarted m = new GettingStarted(); m.createAndShowGUI(); } /** * Creates the and show gui. */ private void createAndShowGUI() { //Create and set up the window. JFrame frame = new JFrame("IconDisplayer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Create circular gauge which holds circular scale. 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); //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); //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); //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)); //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); 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); GridLayout gl = new GridLayout(1,1); frame.setLayout(gl); frame.add(circularGauge); frame.setSize(new Dimension(150, 150)); //Display the window. frame.pack(); frame.setSize(new Dimension(400, 400)); frame.setVisible(true); } }