private void objectEvent(final ObservableDataContainer container) { dataContainer = container; Platform.runLater( () -> { PropertyListener propertyListener = new PropertyListener(); List<BooleanPropertyBase> leftList = dataContainer.getLeftPropertyList(); List<BooleanPropertyBase> rightList = dataContainer.getRigtPropertyList(); dupTableView.setItems(container.getObservableList()); for(int i = 0; i < leftList.size(); i++) { leftList.get(i).addListener(propertyListener); rightList.get(i).addListener(propertyListener); } }); }
public QualityGauge() { aspectRatio = PREFERRED_HEIGHT / PREFERRED_WIDTH; backgroundPaint = Color.TRANSPARENT; borderPaint = Color.TRANSPARENT; borderWidth = 0d; model = GaugeBuilder.create() .minValue(0) .maxValue(10) .startAngle(0) .angleRange(180) .sectionsVisible(true) .sections(NORMAL_ORDER) .build(); reverseOrder = new BooleanPropertyBase(false) { @Override protected void invalidated() { model.setSections(get() ? REVERSE_ORDER : NORMAL_ORDER); } @Override public Object getBean() { return QualityGauge.this; } @Override public String getName() { return "reverseOrder"; } }; setAlignment(Pos.TOP_CENTER); init(); initGraphics(); registerListeners(); }
public Btn(final String TEXT) { getStyleClass().setAll("btn"); rounded = new BooleanPropertyBase(false) { @Override public Object getBean() { return Btn.this; } @Override public String getName() { return "rounded"; } }; buttonColor = new ObjectPropertyBase<Color>(Color.WHITE) { @Override public Object getBean() { return Btn.this; } @Override public String getName() { return "buttonColor"; } }; thumbColor = new ObjectPropertyBase<Color>(Color.WHITE) { @Override public Object getBean() { return Btn.this; } @Override public String getName() { return "thumbColor"; } }; textColor = new ObjectPropertyBase<Color>(Color.WHITE) { @Override public Object getBean() { return Btn.this; } @Override public String getName() { return "textColor"; } }; text = new StringPropertyBase(TEXT) { @Override public Object getBean() { return Btn.this; } @Override public String getName() { return "textOn"; } }; disabledProperty().addListener(o -> setOpacity(isDisabled() ? 0.4 : 1.0)); }
public CardBox(final Card... CARDS) { super(CARDS); cards = FXCollections.observableArrayList(); cards.addAll(CARDS); firstTime = true; open = new BooleanPropertyBase(false) { @Override protected void invalidated() { handleState(get()); } @Override public Object getBean() { return CardBox.this; } @Override public String getName() { return "open"; } }; cardHandler = e -> handleCardSelect((Card) e.getSource()); selectedCard = cards.size() == 0 ? null : cards.get(cards.size() - 1); openTransition = new ParallelTransition(); closeTransition = new SequentialTransition(); initGraphics(); registerListeners(); }
public QualityGauge() { aspectRatio = PREFERRED_HEIGHT / PREFERRED_WIDTH; backgroundPaint = Color.TRANSPARENT; borderPaint = Color.TRANSPARENT; borderWidth = 0d; model = GaugeBuilder.create() .minValue(0) .maxValue(10) .startAngle(0) .angleRange(180) .sectionsVisible(true) .sections(NORMAL_ORDER) .build(); reverseOrder = new BooleanPropertyBase(false) { @Override protected void invalidated() { model.setSections(get() ? REVERSE_ORDER : NORMAL_ORDER); } @Override public Object getBean() { return QualityGauge.this; } @Override public String getName() { return "reverseOrder"; } }; init(); initGraphics(); registerListeners(); }
public static void includePseudoClassWhen(Node node, PseudoClass pseudoClass, ObservableValue<? extends Boolean> condition) { BooleanProperty pseudoClassState = new BooleanPropertyBase(false) { @Override protected void invalidated() { node.pseudoClassStateChanged(pseudoClass, get()); } @Override public Object getBean() { return node; } @Override public String getName() { return pseudoClass.getPseudoClassName(); } }; pseudoClassState.bind(condition); }
public Alarm() { getStyleClass().add("alarm"); currentValue = new BooleanPropertyBase(false) { @Override public Object getBean() { return Alarm.this; } @Override public String getName() { return "currentValue"; } }; name = new SimpleStringProperty(Alarm.this, "name", ""); }
@Override public Void call(Pair<ObservableList<Integer>, Boolean> pair) { List<BooleanPropertyBase> leftList = dataContainer.getLeftPropertyList(); for(Integer index : pair.first) { if(pair.second.booleanValue()) leftList.get(index.intValue()).set(true); else if(leftList.get(index.intValue()).get()) leftList.get(index.intValue()).set(false); } return null; }
@Override public Void call(Pair<ObservableList<Integer>, Boolean> pair) { List<BooleanPropertyBase> rightList = dataContainer.getRigtPropertyList(); for(Integer index : pair.first) { if(pair.second.booleanValue()) rightList.get(index.intValue()).set(true); else if(rightList.get(index.intValue()).get()) rightList.get(index.intValue()).set(false); } return null; }
public ObservableDataContainer(ObservableList<DupData> list, List<BooleanPropertyBase> leftList, List<BooleanPropertyBase> rightList, Map<BooleanPropertyBase, BooleanPropertyBase> propertyMap, Map<String, String> deviceMap) { this.observableList = list; this.booleanLeftPropertyList = leftList; this.booleanRightPropertyList = rightList; this.booleanPropertyMap = propertyMap; this.deviceMap = deviceMap; }
public Segment(final boolean ACTIVE) { getStylesheets().add(Segment.class.getResource("styles.css").toExternalForm()); getStyleClass().add("segment"); timeline = new Timeline(); active = new BooleanPropertyBase(ACTIVE) { @Override public Object getBean() { return Segment.this; } @Override public String getName() { return "active"; } }; init(); initGraphics(); registerListeners(); }
public MyControl() { getStyleClass().add("my-control"); on = new BooleanPropertyBase(false) { @Override protected void invalidated() { pseudoClassStateChanged(ON_PSEUDO_CLASS, get()); } @Override public Object getBean() { return MyControl.this; } @Override public String getName() { return "on"; } }; color = new SimpleStyleableObjectProperty<>(COLOR, MyControl.this, "color"); _value = 0; }
public Led() { on = new BooleanPropertyBase(false) { @Override protected void invalidated() { pseudoClassStateChanged(ON_PSEUDO_CLASS, get()); } @Override public Object getBean() { return this; } @Override public String getName() { return "on"; } }; color = new SimpleStyleableObjectProperty<>(COLOR, this, "color"); initGraphics(); registerListeners(); }
public CustomControl(final SkinType SKIN_TYPE) { getStyleClass().add("custom-control"); skinType = SKIN_TYPE; on = new BooleanPropertyBase(false) { @Override protected void invalidated() { pseudoClassStateChanged(ON_PSEUDO_CLASS, get()); } @Override public Object getBean() { return this; } @Override public String getName() { return "on"; } }; color = new SimpleStyleableObjectProperty<>(COLOR, this, "color"); }
/** * Channelist ChannelCell */ public ChannelCell() { this.isOnline = new BooleanPropertyBase() { @Override public void invalidated() { pseudoClassStateChanged(ONLINE_PSEUDOCLASS, get()); } @Override public String getName() { return "online"; } @Override public Object getBean() { return ChannelCell.this; } }; getStyleClass().add("channel-cell"); this.isPlaylist = new BooleanPropertyBase() { @Override public void invalidated() { pseudoClassStateChanged(PLAYLIST_PSEUDOCLASS, get()); } @Override public String getName() { return "isPlaylist"; } @Override public Object getBean() { return ChannelCell.this; } }; getStyleClass().add("channel-cell"); this.hasReminder = new SimpleBooleanProperty(); }
private BooleanProperty createMainMenuVisibleProperty() { BooleanProperty mainMenuVisibleProperty = new BooleanPropertyBase(true) { @Override public String getName() { return "mainMenuVisibleProperty"; } @Override public Object getBean() { return this; } }; mainMenuVisibleProperty.addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { onMainMenuShow(); } else if (tabsProperty.size() > 0) { onMainMenuHide(); } } }); return mainMenuVisibleProperty; }
@Override protected String call() throws Exception { final List<BooleanPropertyBase> leftList = dataContainer.getLeftPropertyList(); final List<BooleanPropertyBase> rightList = dataContainer.getRigtPropertyList(); final ObservableList<DupData> dupDataList = dataContainer.getObservableList(); if(isWindows) buff.append("@setlocal\n"); else buff.append("#!/bin/sh\n"); for(Entry<String, String> entry : dataContainer.getDeviceMap().entrySet()) { if(isWindows) { buff.append("set "); buff.append(entry.getKey().toUpperCase()).append("=").append(entry.getValue().replace('/', '\\')).append("\n"); } else buff.append(entry.getKey().toUpperCase()).append("=").append(entry.getValue()).append("\n"); } for(int i = 0; i < leftList.size(); i++) { if(leftList.get(i).get()) { if(isWindows) { buff.append("del \"%").append(dupDataList.get(i).getDevice1().toUpperCase()).append("%"); buff.append(dupDataList.get(i).getFile1().replace('/', '\\')).append("\"\n"); } else { buff.append("rm \"${").append(dupDataList.get(i).getDevice1().toUpperCase()).append("}"); buff.append(dupDataList.get(i).getFile1()).append("\"\n"); } } else if(rightList.get(i).get()) { if(isWindows) { buff.append("del \"%").append(dupDataList.get(i).getDevice2().toUpperCase()).append("%"); buff.append(dupDataList.get(i).getFile2().replace('/', '\\')).append("\"\n"); } else { buff.append("rm \"${").append(dupDataList.get(i).getDevice2().toUpperCase()).append("}"); buff.append(dupDataList.get(i).getFile2()).append("\"\n"); } } } if(isWindows) { buff.append("@endlocal"); } return buff.toString(); }
@Override protected String call() throws Exception { try { LineNumberReader reader = new LineNumberReader(new FileReader(file)); ObservableList<DupData> tableDataModel = FXCollections.<DupData> observableArrayList(); Map<String, String> deviceMap = new HashMap<String, String>(); try { int txtLen = 0; while(reader.ready()) { String line = reader.readLine(); String[] group = dupPattern.split(line.subSequence(0, line.length())); if(group.length > 0) { if(group.length == 3 && group[0].equals("data")) deviceMap.put(group[1], group[2]); else if(group.length == 7 && group[0].equals("dup")) { String[] devices = new String[2]; String[] files = new String[2]; int[] offsets = new int[2]; devices[0] = group[1]; devices[1] = group[3]; files[0] = group[2]; files[1] = group[4]; offsets[0] = txtLen; offsets[1] = txtLen + line.length(); tableDataModel.add(new DupData(devices, files, Long.parseLong(group[5]), offsets)); } } txtLen += line.length(); txtLen++; // increment needed for line feed. buff.append(line).append("\n"); } } finally { reader.close(); } Map<BooleanPropertyBase, BooleanPropertyBase> booleanPropertyMap = new HashMap<>();; List<BooleanPropertyBase> booleanLeftPropertyList = new ArrayList<>(tableDataModel.size()); List<BooleanPropertyBase> booleanRightPropertyList = new ArrayList<>(tableDataModel.size()); for(int i = 0; i < tableDataModel.size(); i++) { BooleanPropertyBase propertyLeft = new SimpleBooleanProperty(); BooleanPropertyBase propertyRight = new SimpleBooleanProperty(); booleanLeftPropertyList.add(propertyLeft); booleanRightPropertyList.add(propertyRight); booleanPropertyMap.put(propertyLeft, propertyRight); booleanPropertyMap.put(propertyRight, propertyLeft); } ObjectEventDispatcher.postObject(new ObservableDataContainer(tableDataModel, booleanLeftPropertyList, booleanRightPropertyList, booleanPropertyMap, deviceMap)); return buff.toString(); } catch(Exception e) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); e.printStackTrace(new PrintStream(stream)); return stream.toString(); } }
@Override protected String call() throws Exception { final List<BooleanPropertyBase> leftList = dataContainer.getLeftPropertyList(); final List<BooleanPropertyBase> rightList = dataContainer.getRigtPropertyList(); final ObservableList<DupData> dupDataList = dataContainer.getObservableList(); final Map<String, String> deviceMap = dataContainer.getDeviceMap(); FileSystem fs = FileSystems.getDefault(); buff.setLength(0); for(int i = 0; i < leftList.size(); i++) { final boolean leftSelected = leftList.get(i).get(); final boolean rightSelected = rightList.get(i).get(); if(leftSelected || rightSelected) { final DupData data = dupDataList.get(i); final Path fileName1 = fs.getPath(deviceMap.get(data.getDevice1()), data.getFile1()); final Path fileName2 = fs.getPath(deviceMap.get(data.getDevice2()), data.getFile2()); File file1 = fileName1.toFile(); File file2 = fileName2.toFile(); if(file1.isFile() && file2.isFile()) // both files must exist in order to delete one. { if(leftSelected) { if(file1.delete()) buff.append("Deleted file (1): ").append(fileName1).append("\n"); else buff.append("Failed to delete file (2): ").append(fileName1).append("\n"); } else if(rightSelected) { if(file2.delete()) buff.append("Deleted file (2): ").append(fileName2).append("\n"); else buff.append("Failed to delete file (2): ").append(fileName2).append("\n"); } } else { if(!file1.exists()) buff.append("File (1) does not exist: ").append(fileName1).append("\n"); if(!file2.exists()) buff.append("File (2) does not exist: ").append(fileName2).append("\n"); } } } return buff.toString(); }
public BooleanPropertyBase isOnReadingTabProperty() { return isOnReadingTab; }
public BooleanPropertyBase currentSavedProperty() { return currentSaved; }
public Switch() { getStyleClass().setAll("switch"); rounded = new BooleanPropertyBase(false) { @Override public Object getBean() { return Switch.this; } @Override public String getName() { return "rounded"; } }; selected = new BooleanPropertyBase(false) { @Override protected void invalidated() { if (null != getToggleGroup()) { if (get()) { getToggleGroup().selectToggle(Switch.this); } else if (getToggleGroup().getSelectedToggle() == Switch.this) { getToggleGroup().selectToggle(null); } } fireEvent(new SwitchEvent(Switch.this, null, selected.get() ? SwitchEvent.ON : SwitchEvent.OFF)); } @Override public Object getBean() { return null; } @Override public String getName() { return null; } }; toggleGroup = new ObjectPropertyBase<ToggleGroup>(null) { private ToggleGroup oldToggleGroup; @Override protected void invalidated() { final ToggleGroup toggleGroup = get(); if (null != toggleGroup && !toggleGroup.getToggles().contains(Switch.this)) { if (oldToggleGroup != null) { oldToggleGroup.getToggles().remove(Switch.this); } toggleGroup.getToggles().add(Switch.this); } else if (null == toggleGroup) { oldToggleGroup.getToggles().remove(Switch.this); } oldToggleGroup = toggleGroup; } @Override public Object getBean() { return Switch.this; } @Override public String getName() { return "toggleGroup"; } }; switchColor = new ObjectPropertyBase<Color>(Color.WHITE) { @Override public Object getBean() { return Switch.this; } @Override public String getName() { return "switchColor"; } }; text = new StringPropertyBase("OFF") { @Override public Object getBean() { return Switch.this; } @Override public String getName() { return "text"; } }; selectedText = new StringPropertyBase("ON") { @Override public Object getBean() { return Switch.this; } @Override public String getName() { return "selectedText"; } }; textColor = new ObjectPropertyBase<Color>(Color.WHITE) { @Override public Object getBean() { return Switch.this; } @Override public String getName() { return "switchColorOff"; } }; selectedTextColor = new ObjectPropertyBase<Color>(Color.WHITE) { @Override public Object getBean() { return Switch.this; } @Override public String getName() { return "selectedTextColor"; } }; handlerMap = new ConcurrentHashMap<>(2); disabledProperty().addListener(o -> setOpacity(isDisabled() ? 0.4 : 1.0)); }
public CircularProgressIndicator() { getStylesheets().add(CircularProgressIndicator.class.getResource("circular-progress-indicator.css").toExternalForm()); getStyleClass().add("circular-progress"); progress = new DoublePropertyBase(0) { @Override public void invalidated() { if (get() < 0) { startIndeterminate(); } else { stopIndeterminate(); set(clamp(0d,1d, get())); redraw(); } } @Override public Object getBean() { return CircularProgressIndicator.this;} @Override public String getName() { return "progress"; } }; indeterminate = new BooleanPropertyBase(false) { @Override public Object getBean() { return CircularProgressIndicator.this; } @Override public String getName() { return "indeterminate"; } }; roundLineCap = new BooleanPropertyBase(false) { @Override public void invalidated() { if (get()) { circle.setStrokeLineCap(StrokeLineCap.ROUND); arc.setStrokeLineCap(StrokeLineCap.ROUND); } else { circle.setStrokeLineCap(StrokeLineCap.SQUARE); arc.setStrokeLineCap(StrokeLineCap.SQUARE); } } @Override public Object getBean() { return CircularProgressIndicator.this; } @Override public String getName() { return "roundLineCap"; } }; isRunning = false; timeline = new Timeline(); listener = observable -> { circle.setStrokeDashOffset(dashOffset.get()); circle.getStrokeDashArray().setAll(dashArray_0.getValue(), 200d); }; init(); initGraphics(); registerListeners(); }
public ColorRegulator() { scaleFactor = 1.0; baseColor = Color.YELLOW; targetValue = new DoublePropertyBase(0) { @Override protected void invalidated() { setOn(Double.compare(get(), 0) != 0); } @Override public void set(final double VALUE) { super.set(clamp(MIN_VALUE, MAX_VALUE, VALUE)); } @Override public Object getBean() { return ColorRegulator.this; } @Override public String getName() { return "targetValue"; } }; targetColor = new ObjectPropertyBase<Color>(baseColor) { @Override protected void invalidated() { super.set(null == get() ? Color.BLACK : get()); currentColorCircle.setFill(get()); indicatorRotate.setAngle(((gradientLookup.getValueFrom(baseColor) * 100.0) - MIN_VALUE) * angleStep - ANGLE_RANGE * 0.5); } @Override public Object getBean() { return ColorRegulator.this; } @Override public String getName() { return "targetColor"; } }; textColor = new ObjectPropertyBase<Color>(Color.WHITE) { @Override protected void invalidated() { super.set(null == get() ? Color.WHITE: get()); redraw(); } @Override public Object getBean() { return ColorRegulator.this; } @Override public String getName() { return "textColor"; } }; color = new ObjectPropertyBase<Color>(DEFAULT_COLOR) { @Override protected void invalidated() { super.set(null == get() ? DEFAULT_COLOR : get()); redraw(); } @Override public Object getBean() { return ColorRegulator.this; } @Override public String getName() { return "color"; } }; indicatorColor = new ObjectPropertyBase<Color>(Color.WHITE) { @Override protected void invalidated() { indicatorGlow.setColor(get()); } @Override public Object getBean() { return ColorRegulator.this; } @Override public String getName() { return "indicatorColor"; } }; selected = new BooleanPropertyBase(false) { @Override protected void invalidated() { if (get()) { indicator.setFill(getIndicatorColor()); indicator.setStroke(getIndicatorColor().darker().darker()); indicator.setEffect(indicatorGlow); } else { indicator.setFill(getColor().darker()); indicator.setStroke(getColor().darker().darker()); indicator.setEffect(null); } } @Override public Object getBean() { return ColorRegulator.this; } @Override public String getName() { return "selected"; } }; on = new BooleanPropertyBase(false) { @Override protected void invalidated() { currentColorCircle.setVisible(get()); } @Override public Object getBean() { return ColorRegulator.this; } @Override public String getName() { return "on"; } }; brightness = new DoublePropertyBase(1.0) { @Override protected void invalidated() { set(clamp(0.0, 1.0, get())); targetColor.set(baseColor.deriveColor(0, 1, get(), 1)); } @Override public Object getBean() { return ColorRegulator.this; } @Override public String getName() { return "brightness"; } }; angleStep = ANGLE_RANGE / (MAX_VALUE - MIN_VALUE); init(); initGraphics(); registerListeners(); }
public CircularProgressIndicator() { getStylesheets().add(CircularProgressIndicator.class.getResource("/fxui/css/circular-progress-indicator.css").toExternalForm()); getStyleClass().add("circular-progress"); progress = new DoublePropertyBase(0) { @Override public void invalidated() { if (get() < 0) { startIndeterminate(); } else { stopIndeterminate(); set(clamp(0d,1d, get())); redraw(); } } @Override public Object getBean() { return CircularProgressIndicator.this;} @Override public String getName() { return "progress"; } }; indeterminate = new BooleanPropertyBase(false) { @Override public Object getBean() { return CircularProgressIndicator.this; } @Override public String getName() { return "indeterminate"; } }; roundLineCap = new BooleanPropertyBase(false) { @Override public void invalidated() { if (get()) { circle.setStrokeLineCap(StrokeLineCap.ROUND); arc.setStrokeLineCap(StrokeLineCap.ROUND); } else { circle.setStrokeLineCap(StrokeLineCap.SQUARE); arc.setStrokeLineCap(StrokeLineCap.SQUARE); } } @Override public Object getBean() { return CircularProgressIndicator.this; } @Override public String getName() { return "roundLineCap"; } }; isRunning = false; timeline = new Timeline(); listener = observable -> { circle.setStrokeDashOffset(dashOffset.get()); circle.getStrokeDashArray().setAll(dashArray_0.getValue(), 200d); }; init(); initGraphics(); registerListeners(); }
public List<BooleanPropertyBase> getLeftPropertyList() { return booleanLeftPropertyList; }
public List<BooleanPropertyBase> getRigtPropertyList() { return booleanRightPropertyList; }
public Map<BooleanPropertyBase, BooleanPropertyBase> getPropertyMap() { return booleanPropertyMap; }