Skip to content

Commit

Permalink
Merge pull request #535 from kasemir/java8
Browse files Browse the repository at this point in the history
Java8
  • Loading branch information
kasemir authored May 10, 2019
2 parents e711b3f + 2394009 commit 9475caf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.Border;
import javafx.scene.layout.BorderStroke;
import javafx.scene.layout.BorderStrokeStyle;
import javafx.scene.layout.BorderWidths;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.paint.CycleMethod;
import javafx.scene.paint.LinearGradient;
import javafx.scene.paint.Stop;
import javafx.scene.transform.Scale;

/** Creates JavaFX item for model widget
Expand All @@ -55,7 +55,15 @@
public class EmbeddedDisplayRepresentation extends RegionBaseRepresentation<ScrollPane, EmbeddedDisplayWidget>
{
private static final Background TRANSPARENT_BACKGROUND = new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY));
private static final Border EDIT_BORDER = new Border(new BorderStroke(new Color(0.45, 0.44, 0.43, 0.7), BorderStrokeStyle.DOTTED, CornerRadii.EMPTY, BorderWidths.DEFAULT));
private static final Background EDIT_TRANSPARENT_BACKGROUND = new Background(new BackgroundFill(
new LinearGradient(
0, 0, 10, 10, false, CycleMethod.REPEAT,
new Stop(0.0, new Color(0.53, 0.52, 0.51, 0.15)),
new Stop(0.5, new Color(0.53, 0.52, 0.51, 0.15)),
new Stop(0.5, Color.TRANSPARENT),
new Stop(1.0, Color.TRANSPARENT)
), CornerRadii.EMPTY, Insets.EMPTY
));

private final DirtyFlag dirty_sizes = new DirtyFlag();
private final DirtyFlag dirty_background = new DirtyFlag();
Expand All @@ -72,7 +80,6 @@ public class EmbeddedDisplayRepresentation extends RegionBaseRepresentation<Scro
*/
private volatile Pane inner;
private volatile Background inner_background = Background.EMPTY;
private volatile Border inner_border = Border.EMPTY;

private Scale zoom;
private ScrollPane scroll;
Expand Down Expand Up @@ -286,30 +293,28 @@ private void representContent(final DisplayModel content_model)
private void backgroundChanged(final WidgetProperty<?> property, final Object old_value, final Object new_value)
{
final DisplayModel content_model = active_content_model.get();
// TODO Haven't found perfect way to set the 'background' color
// of the embedded content.
// Setting the 'inner' background will sometimes leave a gray section in the right and or bottom edge
// of the embedded content if the container is (much) larger than the content
// The scroll pane background can only be set via style,
// and then shines through on the outside of the scrollbars
// scroll.setStyle("-fx-control-inner-background: " + JFXUtil.webRGB(content_model.propBackgroundColor().getValue()) +
// "; -fx-background: " + JFXUtil.webRGB(content_model.propBackgroundColor().getValue()));
if (model_widget.propTransparent().getValue())
{
inner_background = TRANSPARENT_BACKGROUND;

// Reinstall the frame in edit mode. Scroll is unusable, so make it with inner
if (toolkit.isEditMode())
inner_border = EDIT_BORDER;
inner_background = EDIT_TRANSPARENT_BACKGROUND;
}
else
{
if (content_model == null)
inner_background = Background.EMPTY;
else
inner_background = new Background(new BackgroundFill(JFXUtil.convert(content_model.propBackgroundColor().getValue()), CornerRadii.EMPTY, Insets.EMPTY));

// TODO Haven't found perfect way to set the 'background' color
// of the embedded content.
// Setting the 'inner' background will sometimes leave a gray section in the right and or bottom edge
// of the embedded content if the container is (much) larger than the content
// The scroll pane background can only be set via style,
// and then shines through on the outside of the scrollbars
// scroll.setStyle("-fx-control-inner-background: " + JFXUtil.webRGB(content_model.propBackgroundColor().getValue()) +
// "; -fx-background: " + JFXUtil.webRGB(content_model.propBackgroundColor().getValue()));
inner_border = Border.EMPTY;
}

dirty_background.mark();
Expand Down Expand Up @@ -353,10 +358,7 @@ else if (resize == Resize.ResizeContent)
}
}
if (dirty_background.checkAndClear())
{
inner.setBackground(inner_background);
inner.setBorder(inner_border);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,24 @@ else if (action.getTarget() == OpenDisplayActionInfo.Target.STANDALONE)
*/
public static void handleClose(final DisplayModel model)
{
final ToolkitRepresentation<Object, Object> toolkit = ToolkitRepresentation.getToolkit(model);

// Called on UI thread
// Stop runtime in background thread
RuntimeUtil.getExecutor().submit(() -> RuntimeUtil.stopRuntime(model) );

// .. while UI thread removes the representation
final ToolkitRepresentation<Object, Object> toolkit = ToolkitRepresentation.getToolkit(model);
toolkit.disposeRepresentation(model);
RuntimeUtil.getExecutor().submit(() ->
{
RuntimeUtil.stopRuntime(model);

model.dispose();
// After runtime stopped and is no longer accessing the model,
// dispose representation.
toolkit.execute(() ->
{
toolkit.disposeRepresentation(model);

// Finally, dispose model
model.dispose();
});
});
}

/** Write a PV
Expand Down

0 comments on commit 9475caf

Please sign in to comment.