List of usage examples for com.google.gwt.user.client Random nextInt
public static native int nextInt(int upperBound) ;
int
between 0 (inclusive) and upperBound
(exclusive) with roughly equal probability of returning any particular int
in this range. From source file:com.gwttest.client.Demo.java
License:Open Source License
private ChartData getAreaHollowChartData() { ChartData cd1 = new ChartData("Volume Consumed", "font-size: 14px; font-family: Verdana; text-align: center;"); cd1.setBackgroundColour("#ffffff"); AreaChart area1 = new AreaChart(); area1.setDotStyle(null);/*from ww w . ja va 2s .c o m*/ area1.setFillAlpha(0.6f); XAxis xa = new XAxis(); int floor = Random.nextInt(3) + 3; double grade = 1.0 + (Random.nextInt(19) + 1) / 10.0; int ln = 0; for (float i = 0; i < 6.2; i += 0.2) { if (ln % 3 == 0) { xa.addLabels("" + ln); } else { xa.addLabels(""); } ln++; area1.addValues(Math.sin(i) * grade + floor); } cd1.setXAxis(xa); cd1.addElements(area1); return cd1; }
From source file:com.gwttest.client.Demo.java
License:Open Source License
private ChartData getAreaLineChartData() { ChartData cd2 = new ChartData("Growth per Region", "font-size: 14px; font-family: Verdana; text-align: center;"); cd2.setBackgroundColour("#ffffff"); XAxis xa = new XAxis(); xa.setLabels("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"); // xa.setMax(12); cd2.setXAxis(xa);/* ww w. j av a2s. c om*/ AreaChart area2 = new AreaChart(); area2.setDotStyle(new HollowDot()); area2.setFillAlpha(0.3f); area2.setColour("#ff0000"); area2.setFillColour("#ff0000"); for (int n = 0; n < 12; n++) { if (n % 3 != 0) area2.addNull(); else area2.addValues(n * Random.nextDouble()); } cd2.addElements(area2); AreaChart area3 = new AreaChart(); SolidDot d = new SolidDot(); d.setSize(2); area3.setDotStyle(d); area3.setFillAlpha(0.3f); area3.setColour("#00aa00"); area3.setFillColour("#00aa00"); int floor = Random.nextInt(3); double grade = (Random.nextInt(4) + 1) / 10.0; for (int n = 0; n < 12; n++) { if (n % 2 != 0) area3.addNull(); else area3.addValues(n * grade + floor); } cd2.addElements(area3); return cd2; }
From source file:com.gwttest.client.Demo.java
License:Open Source License
private ChartData getBarChartGlassData() { ChartData cd2 = new ChartData("Sales by Month 2007", "font-size: 14px; font-family: Verdana; text-align: center;"); cd2.setBackgroundColour("#ffffff"); XAxis xa = new XAxis(); xa.setLabels("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N"); Label l = new Label("Dec", 45); l.setSize(10);//from ww w. j a v a 2 s. c o m l.setColour("#000000"); xa.addLabels(l); cd2.setXAxis(xa); YAxis ya = new YAxis(); ya.setSteps(16); ya.setMax(160); cd2.setYAxis(ya); BarChart bchart2 = new BarChart(BarStyle.GLASS); bchart2.setColour("#00aa00"); bchart2.setTooltip("$#val#"); for (int t = 0; t < 12; t++) { bchart2.addValues(Random.nextInt(50) + 50); } cd2.addElements(bchart2); return cd2; }
From source file:com.gwttest.client.Demo.java
License:Open Source License
private ChartData getBarChartTransparentData() { ChartData cd = new ChartData("Sales by Month 2006", "font-size: 16px; font-weight: bold; font-family: Verdana; color:#ff9900; text-align: center;"); cd.setBackgroundColour("-1"); cd.setDecimalSeparatorComma(true);/*from w w w . ja v a2 s. c o m*/ XAxis xa = new XAxis(); xa.setLabels("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"); xa.getLabels().setColour("#ffff00"); xa.setGridColour("#aaaaff"); xa.setColour("#FF9900"); cd.setXAxis(xa); YAxis ya = new YAxis(); ya.setRange(5000, 20000); ya.setSteps(1000); ya.setGridColour("#aaaaff"); ya.setColour("#FF9900"); cd.setYAxisLabelStyle(10, "#ffff00"); cd.setYAxis(ya); BarChart bchart = new BarChart(BarStyle.NORMAL); bchart.setColour("#000088"); bchart.setTooltip("$#val#"); for (int t = 0; t < 12; t++) { bchart.addValues(Random.nextInt(5000) + 10000); } cd.addElements(bchart); return cd; }
From source file:com.gwttest.client.Demo.java
License:Open Source License
private ChartData getCylinderChartData() { ChartData cd3 = new ChartData("Sales by Quarter 2008", "font-size: 14px; font-family: Verdana; text-align: center;"); cd3.setBackgroundColour("#ffffff"); XAxis xa = new XAxis(); xa.setLabels("Q1", "Q2", "Q3", "Q4"); xa.setZDepth3D(10);/*from w w w.j a v a 2 s . c o m*/ xa.setColour("#909090"); cd3.setXAxis(xa); YAxis ya = new YAxis(); ya.setSteps(16); ya.setMax(160); cd3.setYAxis(ya); CylinderBarChart bchart3 = new CylinderBarChart(); bchart3.setBarwidth(.95); bchart3.setColour("#ff0000"); bchart3.setAlpha(.8f); bchart3.setTooltip("$#val#"); for (int t = 0; t < 4; t++) { bchart3.addValues(Random.nextInt(50) + 50); } cd3.addElements(bchart3); return cd3; }
From source file:com.gwttest.client.Demo.java
License:Open Source License
private ChartData getCylinderChartGlassData() { ChartData cd3 = new ChartData("Sales by Month 2008", "font-size: 14px; font-family: Verdana; text-align: center;"); cd3.setBackgroundColour("#ffffff"); XAxis xa = new XAxis(); xa.setLabels("J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"); xa.setZDepth3D(5);//from ww w. jav a2s. com // xa.setMax(12); xa.setTickHeight(4); xa.setOffset(true); xa.setColour("#B0B0ff"); cd3.setXAxis(xa); YAxis ya = new YAxis(); ya.setSteps(16); ya.setMax(160); cd3.setYAxis(ya); CylinderBarChart bchart3 = new CylinderBarChart(CylinderStyle.GLASS); bchart3.setColour("#9090ff"); bchart3.setAlpha(0.6f); bchart3.setTooltip("$#val#"); for (int t = 0; t < 12; t++) { if (t % 2 == 0) bchart3.addValues(Random.nextInt(50) + 50); else { CylinderBarChart.Bar b = new CylinderBarChart.Bar(Random.nextInt(50) + 50); b.setColour("#90ff90"); bchart3.addBars(b); } } cd3.addElements(bchart3); return cd3; }
From source file:com.gwttest.client.Demo.java
License:Open Source License
private ChartData getHorizBarChartData() { ChartData cd1 = new ChartData("Top Car Speed", "font-size: 14px; font-family: Verdana; text-align: center;"); cd1.setBackgroundColour("#ffffff"); XAxis xa = new XAxis(); xa.setRange(0, 200, 20);//from w w w.j av a2 s . co m cd1.setXAxis(xa); YAxis ya = new YAxis(); ya.addLabels("Ford", "Mazda", "BMW", "Porche"); ya.setOffset(true); cd1.setYAxis(ya); HorizontalBarChart bchart1 = new HorizontalBarChart(); bchart1.setTooltip("#val# mph"); bchart1.addBars(new HorizontalBarChart.Bar(Random.nextInt(87) + 100, "#ffff00")); bchart1.addBars(new HorizontalBarChart.Bar(Random.nextInt(44) + 100, "#0000ff")); bchart1.addBars(new HorizontalBarChart.Bar(Random.nextInt(23) + 100, "#00ff00")); bchart1.addBars(new HorizontalBarChart.Bar(Random.nextInt(33) + 100, "#ff0000")); cd1.addElements(bchart1); cd1.setTooltipStyle(new ToolTip(MouseStyle.FOLLOW)); return cd1; }
From source file:com.gwttest.client.Demo.java
License:Open Source License
private ChartData getHorizontalStackChartData() { ChartData cd = new ChartData("Investments in ($M)", "font-size: 14px; font-family: Verdana; text-align: center;"); cd.setBackgroundColour("#ffffff"); cd.setLegend(new Legend(Position.RIGHT, true)); cd.setTooltipStyle(new ToolTip(MouseStyle.FOLLOW)); HorizontalStackedBarChart stack = new HorizontalStackedBarChart(); stack.setTooltip("#key#<br>#val# / #total#"); stack.setColours(colours);// www . j av a 2s .c o m stack.setBarwidth(0.9); HorizontalStackedBarChart.StackValue v1 = new HorizontalStackedBarChart.StackValue(0, 1000); HorizontalStackedBarChart.StackValue v2 = new HorizontalStackedBarChart.StackValue(1000, 1500); HorizontalStackedBarChart.StackValue v3 = new HorizontalStackedBarChart.StackValue(1500, 1700 + Random.nextInt(12) * 100, "#FF00FF", "Other"); stack.addStack(new HStack(v1, v2, v3)); v1 = new HorizontalStackedBarChart.StackValue(0, 900); v2 = new HorizontalStackedBarChart.StackValue(900, 1700); stack.addStack(new HStack(v1, v2)); v1 = new HorizontalStackedBarChart.StackValue(0, 500); v2 = new HorizontalStackedBarChart.StackValue(500, 2400); stack.addStack(new HStack(v1, v2)); v1 = new HorizontalStackedBarChart.StackValue(0, 1500); v2 = new HorizontalStackedBarChart.StackValue(1500, 2000); v3 = new HorizontalStackedBarChart.StackValue(2000, 2100 + Random.nextInt(8) * 100, "#FF00FF", "Other"); stack.addStack(new HStack(v1, v2, v3)); stack.setKeys(new Keys("Shares", "#ff0000", 13), new Keys("Property", "#00ff00", 13)); XAxis xa = new XAxis(); xa.setRange(0, 3000, 500); cd.setXAxis(xa); YAxis ya = new YAxis(); ya.addLabels("John", "Frank", "Mary", "Andy"); ; ya.setOffset(true); cd.setYAxis(ya); cd.addElements(stack); return cd; }
From source file:com.gwttest.client.Demo.java
License:Open Source License
private ChartData getPieChartData() { ChartData cd = new ChartData("Sales by Region", "font-size: 14px; font-family: Verdana; text-align: center;"); cd.setBackgroundColour("#ffffff"); cd.setLegend(new Legend(Position.RIGHT, true)); PieChart pie = new PieChart(); pie.setAlpha(0.5f);/*from w w w . j ava 2 s.c o m*/ pie.setRadius(130); pie.setNoLabels(true); pie.setTooltip("#label# $#val#<br>#percent#"); pie.setGradientFill(true); pie.setColours("#ff0000", "#00aa00", "#0000ff", "#ff9900", "#ff00ff"); pie.addSlices(new PieChart.Slice(Random.nextInt(11) * 1000, "AU")); pie.addSlices(new PieChart.Slice(Random.nextInt(88) * 1000, "USA")); pie.addSlices(new PieChart.Slice(Random.nextInt(62) * 1000, "UK")); pie.addSlices(new PieChart.Slice(Random.nextInt(14) * 1000, "JP")); pie.addSlices(new PieChart.Slice(Random.nextInt(43) * 1000, "EU")); cd.addElements(pie); return cd; }
From source file:com.gwttest.client.Demo.java
License:Open Source License
private ChartData getRadarChartData() { ChartData cd2 = new ChartData("Risk Areas", "font-size: 12px; text-align: left;"); cd2.setBackgroundColour("#ffffff"); RadarAxis ra = new RadarAxis(); ra.setMax(11);/*from w ww. j a v a 2s . co m*/ ra.setStroke(2); ra.setColour("#A1D4B5"); ra.setGridColour("#C0DEBF"); ra.setSpokeLabels("Financial", "Brand", "Legal", "Market", "Service"); cd2.setRadarAxis(ra); AreaChart area2 = new AreaChart(); area2.setDotStyle(null); area2.setFillAlpha(0.3f); area2.setColour("#ff0000"); area2.setFillColour("#ff0000"); area2.setLoop(true); area2.addValues(Random.nextInt(8) + 2, Random.nextInt(8) + 2, Random.nextInt(8) + 2, Random.nextInt(8) + 2, Random.nextInt(8) + 2); cd2.addElements(area2); return cd2; }