use of javafx.scene.control.Tooltip in project latexdraw by arnobl.
the class PreferencesSetter method initialize.
@Override
public void initialize(final URL location, final ResourceBundle resources) {
latexIncludes.setTooltip(new Tooltip(// $NON-NLS-1$
"<html>" + // $NON-NLS-1$
LangTool.INSTANCE.getBundle().getString("PreferencesSetter.1") + // $NON-NLS-1$
"<br>\\usepackage[frenchb]{babel}<br>\\usepackage[utf8]{inputenc}</html>"));
langList.setCellFactory(l -> new LocaleCell());
langList.setButtonCell(new LocaleCell());
langList.getItems().addAll(LangTool.INSTANCE.getSupportedLocales());
unitChoice.getItems().addAll(Arrays.stream(Unit.values()).map(Unit::getLabel).collect(Collectors.toList()));
styleList.getItems().addAll(GridStyle.values());
buttonOpen.setOnAction(evt -> {
final File file = getFileChooser().showDialog(null);
if (file != null) {
pathOpenField.setText(file.getPath());
}
});
buttonExport.setOnAction(evt -> {
final File file = getFileChooser().showDialog(null);
if (file != null) {
pathExportField.setText(file.getPath());
exporter.setPathExport(file.getPath());
}
});
}
use of javafx.scene.control.Tooltip in project tilesfx by HanSolo.
the class Tile method init.
// ******************** Initialization ************************************
private void init() {
_minValue = 0;
_maxValue = 100;
value = new DoublePropertyBase(_minValue) {
private void update() {
final double VALUE = get();
withinSpeedLimit = !(Instant.now().minusMillis(getAnimationDuration()).isBefore(lastCall));
lastCall = Instant.now();
if (isAnimated() && withinSpeedLimit) {
long animationDuration = isReturnToZero() ? (long) (0.2 * getAnimationDuration()) : getAnimationDuration();
timeline.stop();
final KeyValue KEY_VALUE = new KeyValue(currentValue, VALUE, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
final KeyFrame KEY_FRAME = new KeyFrame(Duration.millis(animationDuration), KEY_VALUE);
timeline.getKeyFrames().setAll(KEY_FRAME);
timeline.play();
} else {
currentValue.set(VALUE);
fireTileEvent(FINISHED_EVENT);
}
if (isAveragingEnabled()) {
movingAverage.addData(new TimeData(VALUE));
}
}
@Override
protected void invalidated() {
update();
}
@Override
public void set(final double VALUE) {
// only get invalid if the the new value is different from the old value
if (Helper.equals(VALUE, getFormerValue())) {
update();
}
super.set(VALUE);
fireTileEvent(VALUE_EVENT);
}
@Override
public Object getBean() {
return Tile.this;
}
@Override
public String getName() {
return "value";
}
};
oldValue = new SimpleDoubleProperty(Tile.this, "oldValue", value.get());
currentValue = new DoublePropertyBase(value.get()) {
@Override
protected void invalidated() {
final double VALUE = get();
if (isCheckThreshold()) {
double thrshld = getThreshold();
if (formerValue.get() < thrshld && VALUE > thrshld) {
fireTileEvent(EXCEEDED_EVENT);
} else if (formerValue.get() > thrshld && VALUE < thrshld) {
fireTileEvent(UNDERRUN_EVENT);
}
}
if (VALUE < getMinMeasuredValue()) {
setMinMeasuredValue(VALUE);
} else if (VALUE > getMaxMeasuredValue()) {
setMaxMeasuredValue(VALUE);
}
formerValue.set(VALUE);
}
@Override
public void set(final double VALUE) {
super.set(VALUE);
}
@Override
public Object getBean() {
return Tile.this;
}
@Override
public String getName() {
return "currentValue";
}
};
formerValue = new SimpleDoubleProperty(Tile.this, "formerValue", value.get());
_range = _maxValue - _minValue;
_threshold = _maxValue;
_referenceValue = _minValue;
_autoReferenceValue = true;
currentTime = new LongPropertyBase(getTime().toEpochSecond()) {
@Override
public Object getBean() {
return Tile.this;
}
@Override
public String getName() {
return "currentTime";
}
};
_title = "";
_titleAlignment = TextAlignment.LEFT;
_description = "";
_descriptionAlignment = Pos.TOP_RIGHT;
_unit = "";
oldFlipText = "";
_flipText = "";
_active = false;
_text = "";
_textAlignment = TextAlignment.LEFT;
_averagingEnabled = false;
_averagingPeriod = 10;
_duration = LocalTime.of(1, 0);
_currentLocation = new Location(0, 0);
_trackColor = TileColor.BLUE;
_mapProvider = MapProvider.BW;
flipTimeInMS = 500;
_textSize = TextSize.NORMAL;
_roundedCorners = true;
_startFromZero = false;
_returnToZero = false;
_minMeasuredValue = _maxValue;
_maxMeasuredValue = _minValue;
_minMeasuredValueVisible = false;
_maxMeasuredValueVisible = false;
_oldValueVisible = false;
_valueVisible = true;
_foregroundColor = FOREGROUND;
_backgroundColor = BACKGROUND;
_borderColor = Color.TRANSPARENT;
_borderWidth = 1;
_knobColor = FOREGROUND;
_activeColor = BLUE;
_animated = false;
animationDuration = 800;
_startAngle = 0;
_angleRange = 180;
_angleStep = _angleRange / _range;
_autoScale = true;
_shadowsEnabled = false;
_locale = Locale.US;
_numberFormat = NumberFormat.getInstance(_locale);
_decimals = 1;
_tickLabelDecimals = 1;
_needleColor = FOREGROUND;
_hourColor = FOREGROUND;
_minuteColor = FOREGROUND;
_secondColor = FOREGROUND;
_barColor = BLUE;
_barBackgroundColor = BACKGROUND;
_titleColor = FOREGROUND;
_descriptionColor = FOREGROUND;
_unitColor = FOREGROUND;
_valueColor = FOREGROUND;
_textColor = FOREGROUND;
_dateColor = FOREGROUND;
_hourTickMarkColor = FOREGROUND;
_minuteTickMarkColor = FOREGROUND;
_alarmColor = FOREGROUND;
_thresholdColor = RED;
_checkSectionsForValue = false;
_checkThreshold = false;
_innerShadowEnabled = false;
_thresholdVisible = false;
_averageVisible = false;
_sectionsVisible = false;
_sectionsAlwaysVisible = false;
_sectionTextVisible = false;
_sectionIconsVisible = false;
_highlightSections = false;
_orientation = Orientation.HORIZONTAL;
_keepAspect = true;
_customFontEnabled = false;
_customFont = Fonts.latoRegular(12);
_alert = false;
_alertMessage = "";
_smoothing = false;
_secondsVisible = false;
_discreteSeconds = true;
_discreteMinutes = true;
_discreteHours = false;
_textVisible = true;
_dateVisible = false;
_running = false;
_hourTickMarksVisible = true;
_minuteTickMarksVisible = true;
_alarmsEnabled = false;
_alarmsVisible = false;
_strokeWithGradient = false;
_fillWithGradient = false;
tooltip = new Tooltip(null);
_xAxis = new CategoryAxis();
_yAxis = new NumberAxis();
_radarChartMode = Mode.POLYGON;
_chartGridColor = Tile.GRAY;
_sortedData = true;
_dataPointsVisible = false;
_snapToTicks = false;
_minorTickCount = 0;
_majorTickUnit = 1;
_matrixSize = new int[] { 30, 25 };
_chartType = ChartType.LINE;
_tooltipTimeout = 2000;
_notificationBackgroundColor = Tile.YELLOW;
_notificationForegroundColor = Tile.BACKGROUND;
updateInterval = LONG_INTERVAL;
increment = 1;
originalMinValue = -Double.MAX_VALUE;
originalMaxValue = Double.MAX_VALUE;
originalThreshold = Double.MAX_VALUE;
lastCall = Instant.now();
timeline = new Timeline();
timeline.setOnFinished(e -> {
if (isReturnToZero() && !Helper.equals(currentValue.get(), 0.0)) {
final KeyValue KEY_VALUE2 = new KeyValue(value, 0, Interpolator.SPLINE(0.5, 0.4, 0.4, 1.0));
final KeyFrame KEY_FRAME2 = new KeyFrame(Duration.millis((long) (0.8 * getAnimationDuration())), KEY_VALUE2);
timeline.getKeyFrames().setAll(KEY_FRAME2);
timeline.play();
}
fireTileEvent(FINISHED_EVENT);
});
}
use of javafx.scene.control.Tooltip in project tilesfx by HanSolo.
the class DonutChartTileSkin method initGraphics.
// ******************** Initialization ************************************
@Override
protected void initGraphics() {
super.initGraphics();
chartEventListener = e -> redraw();
tile.getChartData().forEach(chartData -> chartData.addChartDataEventListener(chartEventListener));
chartDataListener = c -> {
while (c.next()) {
if (c.wasAdded()) {
c.getAddedSubList().forEach(addedItem -> addedItem.addChartDataEventListener(chartEventListener));
} else if (c.wasRemoved()) {
c.getRemoved().forEach(removedItem -> removedItem.removeChartDataEventListener(chartEventListener));
}
}
drawChart();
drawLegend();
};
clickHandler = e -> {
double x = e.getX();
double y = e.getY();
double startAngle = 90;
double angle = 0;
List<ChartData> dataList = tile.isSortedData() ? tile.getChartData().stream().sorted(Comparator.comparingDouble(ChartData::getValue)).collect(Collectors.toList()) : tile.getChartData();
int noOfItems = dataList.size();
double sum = dataList.stream().mapToDouble(ChartData::getValue).sum();
double stepSize = 360.0 / sum;
double barWidth = chartCanvas.getWidth() * 0.1;
double ri = outerRadius - barWidth * 0.5;
double ro = outerRadius + barWidth * 0.5;
for (int i = 0; i < noOfItems; i++) {
ChartData data = dataList.get(i);
double value = data.getValue();
startAngle -= angle;
angle = value * stepSize;
boolean hit = Helper.isInRingSegment(x, y, centerX, centerY, ro, ri, startAngle, angle);
if (hit) {
String tooltipText = new StringBuilder(data.getName()).append("\n").append(String.format(locale, formatString, value)).toString();
Point2D popupLocation = new Point2D(e.getScreenX() - selectionTooltip.getWidth() * 0.5, e.getScreenY() - size * 0.025 - selectionTooltip.getHeight());
selectionTooltip.setText(tooltipText);
selectionTooltip.setX(popupLocation.getX());
selectionTooltip.setY(popupLocation.getY());
selectionTooltip.show(tile.getScene().getWindow());
tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, data));
break;
}
}
};
moveHandler = e -> selectionTooltip.hide();
titleText = new Text();
titleText.setFill(tile.getTitleColor());
Helper.enableNode(titleText, !tile.getTitle().isEmpty());
text = new Text(tile.getText());
text.setFill(tile.getTextColor());
Helper.enableNode(text, tile.isTextVisible());
chartCanvas = new Canvas(size * 0.9, tile.isTextVisible() ? height - size * 0.28 : height - size * 0.205);
chartCtx = chartCanvas.getGraphicsContext2D();
legendCanvas = new Canvas(size * 0.225, tile.isTextVisible() ? height - size * 0.28 : height - size * 0.205);
legendCtx = legendCanvas.getGraphicsContext2D();
selectionTooltip = new Tooltip("");
selectionTooltip.setWidth(60);
selectionTooltip.setHeight(48);
Tooltip.install(chartCanvas, selectionTooltip);
getPane().getChildren().addAll(titleText, legendCanvas, chartCanvas, text);
}
use of javafx.scene.control.Tooltip in project tilesfx by HanSolo.
the class SunburstChart method createSegment.
private Path createSegment(final double START_ANGLE, final double END_ANGLE, final double INNER_RADIUS, final double OUTER_RADIUS, final Color FILL, final Color STROKE, final TreeNode NODE) {
double startAngleRad = Math.toRadians(START_ANGLE + 90);
double endAngleRad = Math.toRadians(END_ANGLE + 90);
boolean largeAngle = Math.abs(END_ANGLE - START_ANGLE) > 180.0;
double x1 = centerX + INNER_RADIUS * Math.sin(startAngleRad);
double y1 = centerY - INNER_RADIUS * Math.cos(startAngleRad);
double x2 = centerX + OUTER_RADIUS * Math.sin(startAngleRad);
double y2 = centerY - OUTER_RADIUS * Math.cos(startAngleRad);
double x3 = centerX + OUTER_RADIUS * Math.sin(endAngleRad);
double y3 = centerY - OUTER_RADIUS * Math.cos(endAngleRad);
double x4 = centerX + INNER_RADIUS * Math.sin(endAngleRad);
double y4 = centerY - INNER_RADIUS * Math.cos(endAngleRad);
MoveTo moveTo1 = new MoveTo(x1, y1);
LineTo lineTo2 = new LineTo(x2, y2);
ArcTo arcTo3 = new ArcTo(OUTER_RADIUS, OUTER_RADIUS, 0, x3, y3, largeAngle, true);
LineTo lineTo4 = new LineTo(x4, y4);
ArcTo arcTo1 = new ArcTo(INNER_RADIUS, INNER_RADIUS, 0, x1, y1, largeAngle, false);
Path path = new Path(moveTo1, lineTo2, arcTo3, lineTo4, arcTo1);
path.setFill(FILL);
path.setStroke(STROKE);
String tooltipText = new StringBuilder(NODE.getData().getName()).append("\n").append(String.format(Locale.US, formatString, NODE.getData().getValue())).toString();
Tooltip.install(path, new Tooltip(tooltipText));
path.setOnMousePressed(new WeakEventHandler<>(e -> NODE.getTreeRoot().fireTreeNodeEvent(new TreeNodeEvent(NODE, EventType.NODE_SELECTED))));
return path;
}
use of javafx.scene.control.Tooltip in project tilesfx by HanSolo.
the class MatrixTileSkin method initGraphics.
// ******************** Initialization ************************************
@Override
protected void initGraphics() {
super.initGraphics();
matrix = PixelMatrixBuilder.create().pixelShape(PixelShape.SQUARE).useSpacer(true).squarePixels(false).colsAndRows(tile.getMatrixSize()).pixelOnColor(tile.getBarColor()).pixelOffColor(Helper.isDark(tile.getBackgroundColor()) ? tile.getBackgroundColor().brighter() : tile.getBackgroundColor().darker()).build();
if (!tile.getChartData().isEmpty() && tile.getChartData().size() > 2) {
matrix.setColsAndRows(tile.getChartData().size(), matrix.getRows());
}
chartEventListener = e -> updateMatrixWithChartData();
tile.getChartData().forEach(chartData -> chartData.addChartDataEventListener(chartEventListener));
chartDataListener = c -> {
while (c.next()) {
if (c.wasAdded()) {
c.getAddedSubList().forEach(addedItem -> addedItem.addChartDataEventListener(chartEventListener));
if (!tile.getChartData().isEmpty() && tile.getChartData().size() > 2) {
matrix.setColsAndRows(tile.getChartData().size(), matrix.getRows());
}
} else if (c.wasRemoved()) {
c.getRemoved().forEach(removedItem -> removedItem.removeChartDataEventListener(chartEventListener));
if (!tile.getChartData().isEmpty() && tile.getChartData().size() > 2) {
matrix.setColsAndRows(tile.getChartData().size(), matrix.getRows());
}
}
}
updateMatrixWithChartData();
};
matrixListener = e -> {
if (tile.getChartData().isEmpty()) {
return;
}
int column = e.getX();
ChartData data = tile.getChartData().get(column);
String tooltipText = new StringBuilder(data.getName()).append("\n").append(String.format(locale, formatString, data.getValue())).toString();
Point2D popupLocation = new Point2D(e.getMouseScreenX() - selectionTooltip.getWidth() * 0.5, e.getMouseScreenY() - size * 0.025 - selectionTooltip.getHeight());
selectionTooltip.setText(tooltipText);
selectionTooltip.setX(popupLocation.getX());
selectionTooltip.setY(popupLocation.getY());
selectionTooltip.show(tile.getScene().getWindow());
tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, data));
};
mouseHandler = e -> {
final javafx.event.EventType<? extends MouseEvent> TYPE = e.getEventType();
if (MouseEvent.MOUSE_CLICKED.equals(TYPE)) {
matrix.checkForClick(e);
} else if (MouseEvent.MOUSE_MOVED.equals(TYPE)) {
selectionTooltip.hide();
} else if (MouseEvent.MOUSE_EXITED.equals(TYPE)) {
selectionTooltip.hide();
}
};
titleText = new Text();
titleText.setFill(tile.getTitleColor());
Helper.enableNode(titleText, !tile.getTitle().isEmpty());
text = new Text(tile.getText());
text.setFill(tile.getTextColor());
Helper.enableNode(text, tile.isTextVisible());
selectionTooltip = new Tooltip("");
selectionTooltip.setWidth(60);
selectionTooltip.setHeight(48);
Tooltip.install(matrix, selectionTooltip);
getPane().getChildren().addAll(titleText, matrix, text);
}
Aggregations