-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Interview font size management #98
- Loading branch information
1 parent
26d8d35
commit bb9a816
Showing
7 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/components/interviewPanel/ToolBar/tools/Controllers/PoliceSizeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package components.interviewPanel.ToolBar.tools.Controllers; | ||
|
||
import javafx.beans.property.SimpleBooleanProperty; | ||
import javafx.beans.property.SimpleIntegerProperty; | ||
import javafx.collections.ObservableList; | ||
import javafx.geometry.Insets; | ||
import javafx.geometry.Pos; | ||
import javafx.scene.Node; | ||
import javafx.scene.canvas.Canvas; | ||
import javafx.scene.canvas.GraphicsContext; | ||
import javafx.scene.image.Image; | ||
import javafx.scene.layout.VBox; | ||
import javafx.scene.paint.Color; | ||
|
||
public class PoliceSizeController { | ||
final String increaseIcon = "/images/increase-font.png"; | ||
final String decreaseIcon = "/images/decrease-font.png"; | ||
final String increaseIconDisabled = "/images/increase-font-disabled.png"; | ||
final String decreaseIconDisabled = "/images/decrease-font-disabled.png"; | ||
private VBox vbox; | ||
private Canvas canvas; | ||
private GraphicsContext gc; | ||
private SimpleIntegerProperty fontSize; | ||
private ObservableList<Node> hboxChildrens; | ||
private FontAction fontAction; | ||
|
||
public enum FontAction { | ||
INCREASE, | ||
DECREASE | ||
} | ||
|
||
public PoliceSizeController(ObservableList<Node> hboxChildrens, SimpleIntegerProperty fontSize, FontAction fontAction) { | ||
this.hboxChildrens = hboxChildrens; | ||
vbox = new VBox(); | ||
canvas = new Canvas(35, 35); | ||
this.fontAction = fontAction; | ||
this.fontSize = fontSize; | ||
this.initGraphic(); | ||
} | ||
|
||
public void initGraphic() { | ||
vbox.setAlignment(Pos.CENTER); | ||
vbox.setPadding(new Insets(3)); | ||
gc = canvas.getGraphicsContext2D(); | ||
vbox.getChildren().add(canvas); | ||
gc.setFill(Color.TRANSPARENT); | ||
gc.fillRect(0, 0, 35, 35); | ||
if (this.fontAction.equals(FontAction.INCREASE)) { | ||
gc.drawImage(new Image(increaseIcon), 0, 0, 35, 35); | ||
} else { | ||
gc.drawImage(new Image(decreaseIconDisabled), 0, 0, 35, 35); | ||
} | ||
|
||
vbox.setOnMouseClicked( | ||
(e) -> { | ||
if (this.fontAction.equals(FontAction.INCREASE)) { | ||
fontSize.set(fontSize.get() + 1); | ||
} else { | ||
if (fontSize.get() > 1) { | ||
fontSize.set(fontSize.get() - 1); | ||
} | ||
|
||
} | ||
}); | ||
this.fontSize.addListener((obs, oldValue, newValue) -> { | ||
if (this.fontAction.equals(FontAction.DECREASE)) { | ||
if (newValue.intValue() <= 1) { | ||
this.gc.drawImage(new Image(decreaseIconDisabled), 0, 0, 35, 35); | ||
}else{ | ||
this.gc.drawImage(new Image(decreaseIcon), 0, 0, 35, 35); | ||
} | ||
} | ||
}); | ||
hboxChildrens.add(vbox); | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.