/** * */ override public void afterReportInit() { try { AreaChartProperties areaChartProperties = new AreaChartProperties(); double[][] data = new double[][] { new double[] { 10, 15, 30, 53 }, new double[] { 6, 30, 10, 21 }, new double[] { 20, 25, 20, 8 } }; Paint[] paints = { new Color(0, 255, 0, 100), new Color(255, 0, 0, 100), new Color(0, 0, 255, 100) }; string[] legendLabels = { "Games", "Events", "Players" }; AxisChartDataSet axisChartDataSet = new AxisChartDataSet(data, legendLabels, paints, ChartType.AREA, areaChartProperties); string[] axisLabels = { "January", "March", "May", "June" }; DataSeries dataSeries = new DataSeries(axisLabels, "Months", "People", "Popular Events"); dataSeries.addIAxisPlotDataSet(axisChartDataSet); ChartProperties chartProperties = new ChartProperties(); AxisProperties axisProperties = new AxisProperties(); axisProperties.setYAxisRoundValuesToNearest(0); LegendProperties legendProperties = new LegendProperties(); AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 500, 350); BufferedImage bufferedImage = new BufferedImage(500, 350, BufferedImage.TYPE_INT_RGB); axisChart.setGraphics2D(bufferedImage.createGraphics()); axisChart.render(); base.setVariableValue("ChartImage", bufferedImage); } catch (ChartDataException chartDataException) { throw new JRScriptletException(chartDataException); } }
public static BufferedImage getJChart() { BufferedImage bufferedImage = null; try { //string reports_dir = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "reports"); //string fileName = System.IO.Path.Combine(reports_dir, "AreaChart.jpg"); //bufferedImage = ImageIO.read(new File(fileName)); AreaChartProperties areaChartProperties = new AreaChartProperties(); double[][] data = new double[][] { new double[] { 10, 15, 30, 53 }, new double[] { 6, 30, 10, 21 }, new double[] { 20, 25, 20, 8 } }; Paint[] paints = { new Color(0, 255, 0, 100), new Color(255, 0, 0, 100), new Color(0, 0, 255, 100) }; String[] legendLabels = { "Games", "Events", "Players" }; AxisChartDataSet axisChartDataSet = new AxisChartDataSet(data, legendLabels, paints, ChartType.AREA, areaChartProperties); String[] axisLabels = { "January", "March", "May", "June" }; DataSeries dataSeries = new DataSeries(axisLabels, "Months", "People", "Popular Events"); dataSeries.addIAxisPlotDataSet(axisChartDataSet); ChartProperties chartProperties = new ChartProperties(); AxisProperties axisProperties = new AxisProperties(); axisProperties.setYAxisRoundValuesToNearest(0); LegendProperties legendProperties = new LegendProperties(); AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 500, 350); bufferedImage = new BufferedImage(500, 350, BufferedImage.TYPE_INT_RGB); axisChart.setGraphics2D(bufferedImage.createGraphics()); axisChart.render(); } catch (ChartDataException chartDataException) { throw new JRScriptletException(chartDataException); } return(bufferedImage); }
public void DrawProperties() { if ((m_axis == Axis.X && !GridSettings.instance.showXAxisOptions) || (m_axis == Axis.Y && !GridSettings.instance.showYAxisOptions) || (m_axis == Axis.Z && !GridSettings.instance.showZAxisOptions)) { return; } AxisProperties axisProperties = m_gridData.GetAxisProperties(m_axis); EditorGUI.BeginChangeCheck(); Color originalBGColor = GUI.backgroundColor; GUI.backgroundColor = GetAxisColor(m_axis); GUIStyle style = new GUIStyle(GUI.skin.box); style.normal.background = EditorTextures.GetByName(EditorTextures.BORDER_TEX_NAME); style.border = new RectOffset(5, 5, 5, 5); if (GridSettings.instance.gridWindowLayout == LayoutDirection.Vertical) { EditorGUILayout.BeginVertical(style); } else { EditorGUILayout.BeginHorizontal(style); } { GUI.backgroundColor = originalBGColor; m_isFoldoutOpen = EditorGUILayout.Foldout(m_isFoldoutOpen, m_axis + " Axis"); if (m_isFoldoutOpen) { // VISIBLE axisProperties.isVisibleInEditor = EditorGUIExtensions.IconToggle(EditorTextures.GetTexturePath(EditorTextures.HIDDEN_ICON), EditorTextures.GetTexturePath(EditorTextures.VISIBLE_ICON), axisProperties.isVisibleInEditor, "Hide the " + m_axis + " grid plane", "Show the " + m_axis + " grid plane"); // SNAP axisProperties.isSnapEnabled = EditorGUIExtensions.IconToggle(EditorTextures.GetTexturePath(EditorTextures.POSITION_SNAP_DISABLED_ICON), EditorTextures.GetTexturePath(EditorTextures.POSITION_SNAP_ENABLED_ICON), axisProperties.isSnapEnabled, "Disable snapping along the " + m_axis + " axis", "Enable snapping along the " + m_axis + " axis"); string unitAbbrev = UnitUtil.Abbreviation(GridSettings.instance.measurementUnit); EditorGUILayout.BeginVertical(); { // CELL SIZE EditorGUIExtensions.DrawIconPrefixedField(EditorTextures.GetTexturePath(EditorTextures.CELL_SIZE_ICON), "Size of cells along the " + m_axis + " axis", delegate { axisProperties.cellSize = (float)EditorUnitUtil.DrawConvertedSizeField(axisProperties.cellSize, Unit.Meter, GridSettings.instance.measurementUnit, GridWindow.MIN_FIELD_WIDTH); axisProperties.cellSize = Mathf.Max(axisProperties.cellSize, MIN_SIZE); EditorGUILayout.LabelField(unitAbbrev, GUILayout.Width(GridWindow.UNIT_LABEL_WIDTH)); }); // GRID OFFSET EditorGUIExtensions.DrawIconPrefixedField(EditorTextures.GetTexturePath(EditorTextures.GRID_OFFSET_ICON), "Offset of the entire grid along the " + m_axis + " axis", delegate { axisProperties.offset = (float)EditorUnitUtil.DrawConvertedSizeField(axisProperties.offset, Unit.Meter, GridSettings.instance.measurementUnit, GridWindow.MIN_FIELD_WIDTH); EditorGUILayout.LabelField(unitAbbrev, GUILayout.Width(GridWindow.UNIT_LABEL_WIDTH)); }); } EditorGUILayout.EndVertical(); // ROTATION EditorGUIExtensions.DrawIconPrefixedField(EditorTextures.GetTexturePath(EditorTextures.ROTATION_SNAP_ANGLE_ICON), "Rotation of the grid around the " + m_axis + " axis", delegate { axisProperties.rotation = EditorGUILayout.FloatField(axisProperties.rotation, GUILayout.MinWidth(GridWindow.MIN_FIELD_WIDTH)); axisProperties.rotation = Util.Wrap(axisProperties.rotation, MIN_AXIS_ROTATION, MAX_AXIS_ROTATION); // degree symbol EditorGUILayout.LabelField(('\u00B0').ToString(), GUILayout.Width(GridWindow.UNIT_LABEL_WIDTH)); }); } GUI.backgroundColor = GetAxisColor(m_axis); } if (GridSettings.instance.gridWindowLayout == LayoutDirection.Vertical) { EditorGUILayout.EndVertical(); } else { EditorGUILayout.EndHorizontal(); } GUI.backgroundColor = originalBGColor; if (EditorGUI.EndChangeCheck()) { EditorUtility.SetDirty(m_gridData); SavePrefs(); } }
private float SnapPositionInternal(GridPoint snapTo, Vector3 gridspacePosition, Axis axis, bool snapEvenIfDisabled) { float gridspaceComponent = gridspacePosition.GetComponent(axis); AxisProperties properties = GetAxisProperties(axis); if (!properties.isSnapEnabled && !snapEvenIfDisabled) { return(gridspaceComponent); } float snapToComponent = snapTo.GetComponent(axis); switch (m_edgeType) { case EdgeType.Infinite: // no changes, just snap to nearest return(snapToComponent); case EdgeType.Free: return(IsOutsideGrid(snapTo) ? gridspaceComponent : snapToComponent); case EdgeType.Clamp: { int gridMin = GetGridMin().GetComponent(axis); int gridMax = GetGridMax().GetComponent(axis); if (snapToComponent < gridMin) { return(gridMin); } else if (snapToComponent > gridMax) { return(gridMax); } else { return(snapToComponent); } } case EdgeType.Wrap: { // while loops will bring snapTo in range of grid and wrap w/ overflow instead of clamping // e.g. on a 1-10 grid, a value of 13 would wrap to 2 (13 - gridSize of 10 = 3, -1 for the 'invisible' // grid space between edges) int gridMin = GetGridMin().GetComponent(axis); int gridMax = GetGridMax().GetComponent(axis); while (snapToComponent < gridMin) { snapToComponent += gridSize + 1; } while (snapToComponent > gridMax) { snapToComponent -= gridSize + 1; } return(snapToComponent); } default: Debug.LogError(string.Format("Grids MX -- Unknown Edge Type: {0}", m_edgeType)); return(gridspaceComponent); } }