/** * Associates an default value {@code node}. * The value will be used alongside a key to resolve a message via the application's {@code MessageSource}. * * @param node the target node on which the key will be registered. * @param defaultValue the value to be registered. * * @since 2.11.0 */ public static void setI18nDefaultValue(@Nonnull Axis<?> node, @Nullable String defaultValue) { requireNonNull(node, ERROR_NODE_NULL); node.getProperties().put(MessageSource.class.getName() + SUFFIX_DEFAULT_VALUE, defaultValue); }
/** * Given graphical coordinates in the reference's coordinate system, returns x and y axis value as * a point via the {@link Axis#getValueForDisplay(double)} and {@link Axis#toNumericValue(Object)} * methods. * * @param minX lower X value (upper left point) * @param minY lower Y value (upper left point) * @param maxX upper X value (bottom right point) * @param maxY upper Y value (bottom right point) */ @SuppressWarnings( "unchecked" ) public Rectangle2D getDataCoordinates( double minX, double minY, double maxX, double maxY ) { if ( minX > maxX || minY > maxY ) { throw new IllegalArgumentException( "min > max for X and/or Y" ); } Axis xAxis = chart.getXAxis(); Axis yAxis = chart.getYAxis(); double xStart = getXShift( xAxis, referenceNode ); double yStart = getYShift( yAxis, referenceNode ); double minDataX = xAxis.toNumericValue( xAxis.getValueForDisplay( minX - xStart ) ); double maxDataX = xAxis.toNumericValue( xAxis.getValueForDisplay( maxX - xStart ) ); //The "low" Y data value is actually at the maxY graphical location as Y graphical axis gets //larger as you go down on the screen. double minDataY = yAxis.toNumericValue( yAxis.getValueForDisplay( maxY - yStart ) ); double maxDataY = yAxis.toNumericValue( yAxis.getValueForDisplay( minY - yStart ) ); return new Rectangle2D( minDataX, minDataY, maxDataX - minDataX, maxDataY - minDataY ); }
public void refresh() { requestChartLayout(); getXAxis().invalidateRange(null); getXAxis().requestAxisLayout(); }
public CalendarChart(Axis<DateTime> xAxis, Axis<CalendarNode> yAxis) { super(xAxis, yAxis); setAnimated(false); xAxis.setAnimated(false); yAxis.setAnimated(false); ObservableList<XYChart.Series<DateTime, CalendarNode>> list = FXCollections.observableArrayList(new ArrayList<XYChart.Series<DateTime, CalendarNode>>()); setData(list); //another hack. we need to remove chart title ObservableList<Node> children = getChildren(); if (!children.isEmpty() && children.get(0) instanceof Label) { children.remove(0); } }
/** * Create the charts. * * @param timeRange * the max time range * @return the {@link LineChart} */ public static LineChart<Number, Number> createDerivativeLineChart(final int timeRange) { final NumberAxis x2Axis = new NumberAxis("Space", -100, 100, 1); final NumberAxis x1Axis = new NumberAxis("Time", 0, timeRange, 1); final LineChart<Number, Number> lineChart = new LineChart<>(x1Axis, x2Axis); lineChart.getYAxis().setAutoRanging(false); lineChart.getYAxis().setAutoRanging(false); lineChart.setAnimated(false); return lineChart; }
private void initChart() { axis = new XYChart.Series<String, Number>(); axis.setName("Measuring points"); chart.getData().add(axis); chart.getYAxis().setLabel("average micro seconds"); }
/** * Returns the plot area in the reference's coordinate space. */ public Rectangle2D getPlotArea() { Axis<?> xAxis = chart.getXAxis(); Axis<?> yAxis = chart.getYAxis(); double xStart = getXShift( xAxis, referenceNode ); double yStart = getYShift( yAxis, referenceNode ); //If the direct method to get the width (which is based on its Node dimensions) is not found to //be appropriate, an alternative method is commented. // double width = xAxis.getDisplayPosition( xAxis.toRealValue( xAxis.getUpperBound() ) ); double width = xAxis.getWidth(); // double height = yAxis.getDisplayPosition( yAxis.toRealValue( yAxis.getLowerBound() ) ); double height = yAxis.getHeight(); return new Rectangle2D( xStart, yStart, width, height ); }
List<DateTime> xData = null; List<CalendarNode> yData = null; if (xAxis.isAutoRanging()) { xData = new ArrayList<>(); if (yAxis.isAutoRanging()) { yData = new ArrayList<>(); xData.add(minDate); xData.add(maxDate); xAxis.invalidateRange(xData); yAxis.invalidateRange(yData);
@Override public void invalidateRange(List<CalendarNode> data) { super.invalidateRange(data); LinkedHashSet<CalendarNode> categoryItems = new LinkedHashSet<>(); categoryItems.addAll(data); allDataCategories.clear(); allDataCategories.addAll(categoryItems); }
Data<DateTime, CalendarNode> item = iter.next(); DateTime startValue = getCurrentDisplayedXValue(item); double xStart = getXAxis().getDisplayPosition(startValue); double yStart = getYAxis().getDisplayPosition(item.getYValue()); CalendarNode node = item.getYValue(); .getExtraValue(); DateTime endVale = barExtras.getEndDate(); double xWidth = getXAxis().getDisplayPosition(endVale) - xStart;
private void initChart() { seriesSystemCpuLoad = new XYChart.Series<Number, Number>(); seriesSystemCpuLoad.setName("SystemCpuLoad"); cpuChart.getData().add(seriesSystemCpuLoad); seriesProcessCpuLoad = new XYChart.Series<Number, Number>(); seriesProcessCpuLoad.setName("ProcessCpuLoad"); cpuChart.getData().add(seriesProcessCpuLoad); cpuChart.getXAxis().setAnimated(false); seriesThread = new XYChart.Series<Number, Number>(); seriesThread.setName("Threads count"); threadChart.getData().add(seriesThread); cpuChart.getXAxis().setAnimated(false); seriesClasses = new XYChart.Series<Number, Number>(); seriesClasses.setName("Total loaded classes"); classesChart.getData().add(seriesClasses); seriesMemory = new XYChart.Series<Number, Number>(); seriesMemory.setName("Memory usage"); memoryChart.getData().add(seriesMemory); seriesFreeSystemMem = new XYChart.Series<Number, Number>(); seriesFreeSystemMem.setName("Free System Memory"); memoryChart.getData().add(seriesFreeSystemMem); cpuChart.getXAxis().setAnimated(false); threadChart.getXAxis().setAnimated(false); classesChart.getXAxis().setAnimated(false); memoryChart.getXAxis().setAnimated(false); // memoryChart.sett }
@Override public void handle( MouseEvent event ) { if ( event.getClickCount() == 2 && event.getButton() == MouseButton.PRIMARY ) { double x = event.getX(); double y = event.getY(); if ( !chartInfo.getXAxisArea().contains( x, y ) ) chartInfo.getChart().getYAxis().setAutoRanging( true ); if ( !chartInfo.getYAxisArea().contains( x, y ) ) chartInfo.getChart().getXAxis().setAutoRanging( true ); } } };
private static void updateLabeled(@Nonnull final Axis<?> node, @Nonnull final GriffonApplication application) { runInsideUIThread(() -> { String key = getI18nKey(node); String args = getI18nArgs(node); String defaultValue = getI18nDefaultValue(node); Object[] argArray = isBlank(args) ? EMPTY_OBJECT_ARRAY : args.split(","); if (isBlank(defaultValue)) { node.setLabel(application.getMessageSource().getMessage(key, argArray, application.getLocale())); } else { node.setLabel(application.getMessageSource().getMessage(key, argArray, application.getLocale(), defaultValue)); } }); }
@Override public void clear() { cpuChart.setAnimated(false); threadChart.setAnimated(false); classesChart.setAnimated(false); memoryChart.setAnimated(false); seriesSystemCpuLoad.getData().clear(); seriesProcessCpuLoad.getData().clear(); seriesThread.getData().clear(); seriesClasses.getData().clear(); seriesMemory.getData().clear(); seriesFreeSystemMem.getData().clear(); cpuChart.getXAxis().setAnimated(true); threadChart.getXAxis().setAnimated(true); classesChart.getXAxis().setAnimated(true); memoryChart.getXAxis().setAnimated(true); } }
/** * Given graphical coordinates in the reference's coordinate system, returns x and y axis value as * a point via the {@link Axis#getValueForDisplay(double)} and {@link Axis#toNumericValue(Object)} * methods. */ @SuppressWarnings( "unchecked" ) public Point2D getDataCoordinates( double x, double y ) { Axis xAxis = chart.getXAxis(); Axis yAxis = chart.getYAxis(); double xStart = getXShift( xAxis, referenceNode ); double yStart = getYShift( yAxis, referenceNode ); return new Point2D( xAxis.toNumericValue( xAxis.getValueForDisplay( x - xStart ) ), yAxis.toNumericValue( yAxis.getValueForDisplay( y - yStart ) ) ); }
/** * Finds out if a {@code default value} has been registered with the target {@code Node}, returning the value if found. * * @param node the target node on which the value may have been registered. * * @return the value registered with the target {@code Node} or {@code null} if not found. * * @since 2.11.0 */ @Nullable public static String getI18nDefaultValue(@Nonnull Axis<?> node) { requireNonNull(node, ERROR_NODE_NULL); return (String) node.getProperties().get(MessageSource.class.getName() + SUFFIX_DEFAULT_VALUE); }
/** * Finds out if an i18n {@code key} has been registered with the target {@code Node}, returning the key if found. * * @param node the target node on which the key may have been registered. * * @return the key registered with the target {@code Node} or {@code null} if not found. * * @since 2.11.0 */ @Nullable public static String getI18nKey(@Nonnull Axis<?> node) { requireNonNull(node, ERROR_NODE_NULL); return (String) node.getProperties().get(MessageSource.class.getName() + SUFFIX_KEY); }
/** * Finds out if an {@code arguments array} has been registered with the target {@code Node}, returning the array if found. * * @param node the target node on which the arguments may have been registered. * * @return the arguments registered with the target {@code Node} or {@code null} if not found. * * @since 2.11.0 */ @Nullable public static String getI18nArgs(@Nonnull Axis<?> node) { requireNonNull(node, ERROR_NODE_NULL); return (String) node.getProperties().get(MessageSource.class.getName() + SUFFIX_ARGS); }
/** * Associates an i18n key to a {@code node}. The key is used to resolve a message via the application's {@code MessageSource}. * * @param node the target node on which the key will be registered. * @param key the message key to be registered. * * @since 2.11.0 */ public static void setI18nKey(@Nonnull Axis<?> node, @Nonnull String key) { requireNonNull(node, ERROR_NODE_NULL); requireNonBlank(key, ERROR_KEY_BLANK); node.getProperties().put(MessageSource.class.getName() + SUFFIX_KEY, key); }
/** * Associates an i18n arrays of arguments to a {@code node}. * These arguments will be used alongside a key to resolve a message via the application's {@code MessageSource}. * * @param node the target node on which the key will be registered. * @param args the array of arguments to be registered. * * @since 2.11.0 */ public static void setI18nArgs(@Nonnull Axis<?> node, @Nullable String args) { requireNonNull(node, ERROR_NODE_NULL); requireNonBlank(args, ERROR_ARGS_BLANK); node.getProperties().put(MessageSource.class.getName() + SUFFIX_ARGS, args); }