Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 77 additions & 1 deletion src/main/java/eu/hansolo/tilesfx/Demo.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import javafx.application.Application;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
Expand All @@ -51,6 +52,8 @@
import javafx.scene.Scene;
import javafx.scene.chart.XYChart;
import javafx.scene.control.Button;
import javafx.scene.control.TableColumn;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.Image;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
Expand Down Expand Up @@ -152,6 +155,8 @@ public class Demo extends Application {
private Tile imageTile;
private Tile timelineTile;
private Tile imageCounterTile;
private Tile ledTile;
private Tile tableTile;


private long lastTimerCall;
Expand Down Expand Up @@ -828,6 +833,46 @@ public class Demo extends Application {
.imageMask(ImageMask.ROUND)
.build();

ledTile = TileBuilder.create()
.skinType(SkinType.LED)
.prefSize(TILE_WIDTH, TILE_HEIGHT)
.title("LED Tile")
.activeColor(new Color(0, 1, 0.2, 1))
.text("Whatever text")
.build();

// setup table tile
TableColumn<String, Person> column1 = new TableColumn<>("First name");
column1.setCellValueFactory(new PropertyValueFactory<>("firstName"));
TableColumn<String, Person> column2 = new TableColumn<>("Last name");
column2.setCellValueFactory(new PropertyValueFactory<>("lastName"));
TableColumn<String, Person> column3 = new TableColumn<>("Birth place");
column3.setCellValueFactory(new PropertyValueFactory<>("birthPlace"));
TableColumn<Integer, Person> column4 = new TableColumn<>("Age");
column4.setCellValueFactory(new PropertyValueFactory<>("age"));
// TableColumn<Integer, Person> column5 = new TableColumn<>("Age");
// column5.setCellValueFactory(new PropertyValueFactory<>("age"));
// TableColumn<Integer, Person> column6 = new TableColumn<>("Loooooong");
// column6.setCellValueFactory(new PropertyValueFactory<>("age"));

Person a = new Person("Long", "Johnson", "Angera", 26);
Person b = new Person("Mike", "Funkyman", "Varese", 28);
Person c = new Person("Scott", "Tuner", "Bologna", 37);
Person d = new Person("Bryce", "Mice", "Comabbio", 47);
Person aa = new Person("Duke", "Lemover", "Angera", 26);
Person bb = new Person("Jason", "Moveon", "Varese", 28);
Person cc = new Person("Why", "Notsure", "Bologna", 37);
Person dd = new Person("Whatever", "Whatever", "Comabbio", 47);

tableTile = TileBuilder.create()
.skinType(SkinType.TABLE)
.prefSize(300, 200)
.title("Table Tile")
.insetsEnabled(false)
.tableColumns(column1, column2, column3, column4)
.tableItems(FXCollections.observableArrayList(a, b, c, d, aa, bb, cc, dd))
.build();

lastTimerCall = System.nanoTime();
timer = new AnimationTimer() {
@Override public void handle(long now) {
Expand Down Expand Up @@ -889,6 +934,8 @@ public class Demo extends Application {

imageCounterTile.increaseValue(1);

ledTile.setValue(Math.round(RND.nextDouble()));

lastTimerCall = now;
}
}
Expand All @@ -910,7 +957,7 @@ public class Demo extends Application {
smoothAreaChartTile, countryTile, ephemerisTile, characterTile,
flipTile, switchSliderTile, dateTile, calendarTile, sunburstTile,
matrixTile, radialPercentageTile, statusTile, barGaugeTile, imageTile,
timelineTile, imageCounterTile);//, weatherTile);
timelineTile, imageCounterTile, ledTile, tableTile);//, weatherTile);

pane.setHgap(5);
pane.setVgap(5);
Expand Down Expand Up @@ -971,4 +1018,33 @@ private void calcNoOfNodes(Node node) {
public static void main(String[] args) {
launch(args);
}


public class Person {
public String firstName;
public String lastName;
public String birthPlace;
public Integer age;


public Person(String firstName, String lastName, String birthPlace, Integer age) {
this.firstName = firstName;
this.lastName = lastName;
this.birthPlace = birthPlace;
this.age = age;
}

public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public String getBirthPlace() {
return birthPlace;
}
public Integer getAge() {
return age;
}
}
}
111 changes: 78 additions & 33 deletions src/main/java/eu/hansolo/tilesfx/Tile.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,7 @@
import javafx.beans.NamedArg;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.BooleanPropertyBase;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.DoublePropertyBase;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.IntegerPropertyBase;
import javafx.beans.property.LongProperty;
import javafx.beans.property.LongPropertyBase;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ObjectPropertyBase;
import javafx.beans.property.ReadOnlyDoubleProperty;
import javafx.beans.property.ReadOnlyLongProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.property.StringPropertyBase;
import javafx.beans.property.*;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
Expand All @@ -79,6 +64,7 @@
import javafx.scene.chart.XYChart.Series;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
import javafx.scene.control.TableColumn;
import javafx.scene.control.Tooltip;
import javafx.scene.image.Image;
import javafx.scene.input.MouseEvent;
Expand Down Expand Up @@ -140,7 +126,8 @@ public enum SkinType { SMOOTHED_CHART("ChartTileSkin"), BAR_CHART("BarChartTileS
RADIAL_PERCENTAGE("RadialPercentageTileSkin"),
STATUS("StatusTileSkin"), BAR_GAUGE("BarGaugeTileSkin"),
IMAGE("ImageTileSkin"), IMAGE_COUNTER("ImageCounterTileSkin"),
TIMELINE("TimelineTileSkin"), CLUSTER_MONITOR("ClusterMonitorTileSkin");
TIMELINE("TimelineTileSkin"), CLUSTER_MONITOR("ClusterMonitorTileSkin"),
LED("LedTileSkin"), TABLE("TableTileSkin");

public final String CLASS_NAME;
SkinType(final String CLASS_NAME) {
Expand Down Expand Up @@ -575,6 +562,14 @@ public enum ImageMask {
private int _numberOfValuesForTrendCalculation;
private IntegerProperty numberOfValuesForTrendCalculation;
private EventHandler<MouseEvent> infoRegionHandler;
private boolean _insetsEnabled;
private BooleanProperty insetsEnabled;
private boolean _contentFill;
private BooleanProperty contentFill;
private TableColumn<?, ?>[] _tableColumns;
private ObjectProperty<TableColumn<?, ?>[]> tableColumns;
private ObservableList<?> _tableItems;
private ObjectProperty<ObservableList<?>> tableItems;

private volatile ScheduledFuture<?> periodicTickTask;
private ScheduledExecutorService periodicTickExecutorService;
Expand Down Expand Up @@ -2578,7 +2573,7 @@ public ObjectProperty<Color> foregroundColorProperty() {
}
return foregroundColor;
}

/**
* Returns the Paint object that will be used to fill the tile background.
* This is usally a Color object.
Expand Down Expand Up @@ -2992,7 +2987,7 @@ public BooleanProperty shadowsEnabledProperty() {
}
return shadowsEnabled;
}

public Locale getLocale() { return null == locale ? _locale : locale.get(); }
public void setLocale(final Locale LOCALE) {
if (null == locale) {
Expand Down Expand Up @@ -3128,7 +3123,7 @@ public IntegerProperty tickLabelDecimalsProperty() {
}
return tickLabelDecimals;
}

/**
* Returns the color that will be used to colorize the needle of
* the radial tiles.
Expand Down Expand Up @@ -3767,7 +3762,7 @@ public BooleanProperty highlightSectionsProperty() {
}
return highlightSections;
}

/**
* Returns the orientation of the control. This feature
* will only be used in the BulletChartSkin and LinearSkin.
Expand Down Expand Up @@ -3802,7 +3797,7 @@ public ObjectProperty<Orientation> orientationProperty() {
}
return orientation;
}

/**
* Returns true if the control should keep it's aspect. This is
* in principle only needed if the control has different width and
Expand Down Expand Up @@ -3994,7 +3989,7 @@ public ZoneId getZoneId() {
return zoneId;
}


/**
* Returns the text that was defined for the clock.
* This text could be used for additional information.
Expand Down Expand Up @@ -4121,7 +4116,7 @@ public void clearTimeSections() {
getTimeSections().clear();
fireTileEvent(SECTION_EVENT);
}

/**
* Returns true if the second hand of the clock should move
* in discrete steps of 1 second. Otherwise it will move continuously like
Expand Down Expand Up @@ -4535,7 +4530,7 @@ public ObjectProperty<Color> tickMarkColorProperty() {
}
return tickMarkColor;
}

/**
* Returns true if the hour tickmarks will be drawn.
* @return true if the hour tickmarks will be drawn
Expand Down Expand Up @@ -5291,12 +5286,12 @@ public void setNotifyRegionForegroundColor(final Color COLOR) {
_notifyRegionForegroundColor = COLOR;
fireTileEvent(REDRAW_EVENT);
}

public String getNotifyRegionTooltipText() { return _notifyRegionTooltipText; }
public void setNotifyRegionTooltipText(final String TEXT) {
_notifyRegionTooltipText = TEXT;
fireTileEvent(REDRAW_EVENT);
}
}

public Color getInfoRegionBackgroundColor() { return _infoRegionBackgroundColor; }
public void setInfoRegionBackgroundColor(final Color COLOR) {
Expand Down Expand Up @@ -5397,7 +5392,7 @@ public StringProperty rightTextProperty() {
}
return rightText;
}

public double getLeftValue() { return null == leftValue ? _leftValue : leftValue.get(); }
public void setLeftValue(final double VALUE) {
if (null == leftValue) {
Expand Down Expand Up @@ -5457,7 +5452,7 @@ public DoubleProperty rightValueProperty() {
}
return rightValue;
}

public Node getLeftGraphics() { return null == leftGraphics ? _leftGraphics : leftGraphics.get(); }
public void setLeftGraphics(final Node NODE) {
if (null == leftGraphics) {
Expand Down Expand Up @@ -5601,6 +5596,48 @@ public void setInfoRegionEventHandler(final EventHandler<MouseEvent> HANDLER) {
fireTileEvent(INFO_REGION_HANDLER_EVENT);
}

public boolean areInsetsEnabled() { return null == insetsEnabled ? _insetsEnabled : insetsEnabled.get(); }

public void setInsetsEnabled(final boolean INSETS_ENABLED) {
if (null == insetsEnabled) { _insetsEnabled = INSETS_ENABLED; } else { insetsEnabled.set(INSETS_ENABLED); }
}
public BooleanProperty insetsEnabledProperty() {
if (null == insetsEnabled) { insetsEnabled = new SimpleBooleanProperty(Tile.this, "insetsEnabled", _insetsEnabled); }
return insetsEnabled;
}

public boolean isContentFill() { return null == contentFill ? _contentFill : contentFill.get(); }

public void setContentFill(final boolean CONTENT_CENTERED) {
if (null == contentFill) { _contentFill = CONTENT_CENTERED; } else { contentFill.set(CONTENT_CENTERED); }
}
public BooleanProperty contentFillProperty() {
if (null == contentFill) { contentFill = new SimpleBooleanProperty(Tile.this, "contentFill", _contentFill); }
return contentFill;
}

public TableColumn<?, ?>[] getTableColumns () { return null == tableColumns ? _tableColumns : tableColumns.get(); }

public void setTableColumns (final TableColumn<?, ?>[] TABLE_COLUMNS) {
if (null == tableColumns) { _tableColumns = TABLE_COLUMNS; } else { tableColumns.set(TABLE_COLUMNS); }
}

public ObjectProperty<TableColumn<?, ?>[]> tableColumnProperty() {
if (null == tableColumns) { tableColumns = new SimpleObjectProperty<>(Tile.this, "tableColumns", _tableColumns); }
return tableColumns;
}

public ObservableList<?> getTableItems () { return null == tableItems ? _tableItems : tableItems.get(); }

public void setTableItems (final ObservableList<?> TABLE_ITEMS) {
if (null == tableItems) { _tableItems = TABLE_ITEMS; } else { tableItems.set(TABLE_ITEMS); }
}

public ObjectProperty<ObservableList<?>> tableItemsProperty () {
if (null == tableItems) { tableItems = new SimpleObjectProperty<>(Tile.this, "tableItems", _tableItems); }
return tableItems;
}

public boolean isShowing() { return null == showing ? false : showing.get(); }
public BooleanBinding showingProperty() { return showing; }

Expand Down Expand Up @@ -5741,7 +5778,7 @@ public void stop() {

private void createShutdownHook() { Runtime.getRuntime().addShutdownHook(new Thread(() -> stop())); }


// ******************** Event handling ************************************
public void setOnTileEvent(final TileEventListener LISTENER) { addTileEventListener(LISTENER); }
public void addTileEventListener(final TileEventListener LISTENER) { if (!tileEventListeners.contains(LISTENER)) tileEventListeners.add(LISTENER); }
Expand All @@ -5756,7 +5793,7 @@ public void fireTileEvent(final TileEvent EVENT) {
}
}


public void setOnAlarm(final AlarmEventListener LISTENER) { addAlarmEventListener(LISTENER); }
public void addAlarmEventListener(final AlarmEventListener LISTENER) { if (!alarmEventListeners.contains(LISTENER)) alarmEventListeners.add(LISTENER); }
public void removeAlarmEventListener(final AlarmEventListener LISTENER) { if (alarmEventListeners.contains(LISTENER)) alarmEventListeners.remove(LISTENER); }
Expand Down Expand Up @@ -5789,9 +5826,9 @@ private void setupBinding() {
return getScene().getWindow().isShowing();
} else {
return false;
}
}
}, sceneProperty(), getScene().windowProperty(), getScene().getWindow().showingProperty());

showing.addListener(o -> {
if (showing.get()) {
while(tileEventQueue.peek() != null) {
Expand Down Expand Up @@ -5851,6 +5888,8 @@ private void setupBinding() {
case IMAGE_COUNTER : return new ImageCounterTileSkin(Tile.this);
case TIMELINE : return new TimelineTileSkin(Tile.this);
case CLUSTER_MONITOR : return new ClusterMonitorTileSkin(Tile.this);
case LED : return new LedTileSkin(Tile.this);
case TABLE : return new TableTileSkin(Tile.this);
default : return new TileSkin(Tile.this);
}
}
Expand Down Expand Up @@ -6016,6 +6055,10 @@ public void presetTileParameters(final SkinType SKIN_TYPE) {
setDecimals(0);
setBarColor(BLUE);
break;
case LED:
break;
case TABLE:
break;
default:
break;
}
Expand Down Expand Up @@ -6067,6 +6110,8 @@ public void setSkinType(final SkinType SKIN_TYPE) {
case IMAGE_COUNTER : setSkin(new ImageCounterTileSkin(Tile.this)); break;
case TIMELINE : setSkin(new TimelineTileSkin(Tile.this)); break;
case CLUSTER_MONITOR : setSkin(new ClusterMonitorTileSkin(Tile.this)); break;
case LED : setSkin(new LedTileSkin(Tile.this)); break;
case TABLE : setSkin((new TableTileSkin(Tile.this))); break;
default : setSkin(new TileSkin(Tile.this)); break;
}
fireTileEvent(RESIZE_EVENT);
Expand Down
Loading