Skip to content
Snippets Groups Projects
Commit 707d1f61 authored by George Adrian Stoica's avatar George Adrian Stoica
Browse files

Added listview related renderer classes

parent 8062dd20
No related branches found
No related tags found
1 merge request!6Issue 11 allow user to enter and update metadata about the latlong points
package simpleex.ui;
import javafx.scene.control.ListCell;
import javafx.scene.layout.Region;
import simpleex.core.LatLong;
/**
*
* @author Adrian Stoica
*
*/
public class LatLongCell extends ListCell<LatLong> {
@Override
public void updateItem(LatLong location, boolean empty) {
super.updateItem(location, empty);
if(empty || location == null) {
setText(null);
setGraphic(null);
setPrefHeight(25.0);
} else {
LatLongCellController latLongCellController = new LatLongCellController();
latLongCellController.setLatLong(location);
setGraphic(latLongCellController.getCellView());
setPrefHeight(Region.USE_COMPUTED_SIZE);
//setPrefHeight(50.0);
}
}
}
package simpleex.ui;
import java.io.IOException;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Label;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import simpleex.core.LatLong;
import simpleex.core.MetaData;
public class LatLongCellController {
@FXML
private VBox vBox;
@FXML
private Label nameLabel;
@FXML
private Label coordinatesLabel;
@FXML
private Label descriptionLabel;
private LatLong latLong;
public LatLongCellController() {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("LatLongCell.fxml"));
fxmlLoader.setController(this);
try {
vBox = fxmlLoader.load();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public void setLatLong(LatLong latLong) {
this.latLong = latLong;
if(latLong != null) {
coordinatesLabel.setText(latLong.toString());
if (this.latLong.hasMetaData()) {
MetaData metaData = this.latLong.getMetaData();
if(metaData.hasProperty(MetaData.NAME_PROPERTY)) {
nameLabel.setText(metaData.getProperty(MetaData.NAME_PROPERTY));
}
else {
nameLabel.setMaxHeight(0.0);
}
if(metaData.hasProperty(MetaData.DESCRIPTION_PROPERTY)) {
descriptionLabel.setText(metaData.getProperty(MetaData.DESCRIPTION_PROPERTY));
descriptionLabel.setWrapText(true);
descriptionLabel.setMaxHeight(50.0);
descriptionLabel.setManaged(true);
descriptionLabel.setMaxWidth(200.0);
}
else {
descriptionLabel.setMaxHeight(0.0);
}
vBox.autosize();
} else {
vBox.setPrefHeight(30.0);
}
}
}
public Region getCellView() {
return this.vBox;
}
}
<?import simpleex.core.LatLong?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<VBox xmlns:fx="http://javafx.com/fxml" fx:id="vBox" fillWidth="true">
<children>
<Label fx:id="nameLabel" />
<Label fx:id="coordinatesLabel" />
<Label fx:id="descriptionLabel" />
</children>
</VBox>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment