Skip to content

Commit

Permalink
Cleaning javafx.App
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Jul 20, 2020
1 parent 0869d80 commit d155a41
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
30 changes: 17 additions & 13 deletions src/main/java/org/luwrain/interaction/javafx/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ public final class App extends Application
{
static private final String LOG_COMPONENT = JavaFxInteraction.LOG_COMPONENT;

static private final int MIN_TABLE_WIDTH = 16;
static private final int MIN_TABLE_HEIGHT = 8;
static private final int
MIN_TABLE_WIDTH = 16,
MIN_TABLE_HEIGHT = 8;

private StackPane rootPane = null;
Stage stage = null;
private Stage stage = null;
private ResizableCanvas textCanvas = null;
private GraphicsContext gc = null;
private Bounds charBounds = null;
Expand Down Expand Up @@ -142,8 +143,6 @@ synchronized boolean initTable()
return true;
}



void setColors(Color fontColor, Color font2color,
Color bkgColor, Color splitterColor)
{
Expand All @@ -168,17 +167,19 @@ void setMargin(int marginLeft,int marginTop,int marginRight,int marginBottom)

void setSizeAndShow(int width, int height)
{
InvalidThreadException.checkThread("App.setSizeAndShow()");
this.canvasWidth = width;
this.canvasHeight = height;
this.rootPane.resize(width,height);
this.rootPane.resize(width, height);
this.stage.sizeToScene();
this.stage.show();
}

void setUndecoratedSizeAndShow(double width,double height)
void setUndecoratedSizeAndShow(double width, double height)
{
this.canvasWidth=width;
this.canvasHeight=height;
InvalidThreadException.checkThread("App.setUndecoratedSizeAndShow()");
this.canvasWidth = width;
this.canvasHeight = height;
this.rootPane.resize(width, height);
//canvas.resize(width, height);
this.stage.initStyle(StageStyle.UNDECORATED); // WARN: can't change style after first window show
Expand Down Expand Up @@ -346,7 +347,7 @@ void remove(Node node)
rootPane.getChildren().remove(node);
}

Font getInteractionFont()
Font getInteractionFont()
{
return font;
}
Expand All @@ -356,8 +357,8 @@ Font getInteractionFont2()
return font;
}

int getTableWidth()
{
int getTableWidth()
{
return tableWidth;
}

Expand All @@ -366,5 +367,8 @@ int getTableHeight()
return tableHeight;
}


Stage getStage()
{
return this.stage;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2012-2018 Michael Pozhidaev <[email protected]>
Copyright 2012-2020 Michael Pozhidaev <[email protected]>
Copyright 2015-2016 Roman Volovodov <[email protected]>
This file is part of LUWRAIN.
Expand Down Expand Up @@ -81,15 +81,15 @@ public final class JavaFxInteraction implements Interaction
Utils.InteractionParamColorToFx(params.splitterColor));
app.setMargin(params.marginLeft,params.marginTop,params.marginRight,params.marginBottom);
this.keyboard = os.getCustomKeyboardHandler("javafx");
app.stage.addEventHandler(KeyEvent.KEY_PRESSED, (event)->{
app.getStage().addEventHandler(KeyEvent.KEY_PRESSED, (event)->{
if (!graphicalMode)
keyboard.onKeyPressed(event);
});
app.stage.addEventHandler(KeyEvent.KEY_RELEASED, (event)->{
app.getStage().addEventHandler(KeyEvent.KEY_RELEASED, (event)->{
if (!graphicalMode)
keyboard.onKeyReleased(event);
});
app.stage.addEventHandler(KeyEvent.KEY_TYPED, (event)->{
app.getStage().addEventHandler(KeyEvent.KEY_TYPED, (event)->{
if (!graphicalMode)
keyboard.onKeyTyped(event);
});
Expand Down Expand Up @@ -328,6 +328,6 @@ public void enableGraphicalMode()
public void disableGraphicalMode()
{
this.graphicalMode = false;
app.stage.requestFocus();
app.getStage().requestFocus();
}
}

0 comments on commit d155a41

Please sign in to comment.