Skip to content

Commit

Permalink
New version
Browse files Browse the repository at this point in the history
  • Loading branch information
Brenin1991 authored Jun 6, 2020
1 parent 2747350 commit beb2bfe
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 26 deletions.
3 changes: 3 additions & 0 deletions src/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: sample.PikSix

50 changes: 45 additions & 5 deletions src/sample/classes/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

import javafx.scene.effect.BoxBlur;
import javafx.scene.effect.DropShadow;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.paint.ImagePattern;
import javafx.scene.shape.Line;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

import java.io.File;


public class Tools {
BoxBlur bb = new BoxBlur();
Expand All @@ -24,12 +30,44 @@ public Rectangle rect(Color fillColor, Color strokeColor, Double posX, Double po
return rectangle;
}

public Circle oval(Color fillColor, Color strokeColor, Double posX, Double posY, Double x, Double lineSize, Double opacity, Double blur, Double shadow){
Circle circle;
circle = new Circle(posX, posY, x);
public Rectangle image(Color fillColor, Color strokeColor, Double posX, Double posY, Double x, Double y, Double lineSize, Double opacity, Double blur, Double shadow){
FileChooser fileChooser = new FileChooser();
Image imagem = null;
fileChooser.setTitle("Open image");
//fileChooser.setInitialDirectory(new File("/home"));
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("PNG File", "*.png"));
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("JPEG File", "*.jpg"));

try{
File file = fileChooser.showOpenDialog(new Stage());
if(file != null){
imagem = new Image(file.toURI().toString());

//ImageIO.write(SwingFXUtils.fromFXImage(snapshot,null), "png", selectedFile);
}
} catch (Exception e){

}


Rectangle rectangle;
rectangle = new Rectangle(posX, posY, x, y);
rectangle.setStrokeWidth(lineSize);
rectangle.setFill(new ImagePattern(imagem));
rectangle.setStroke(strokeColor);
rectangle.setOpacity(opacity/100);

return rectangle;
}

public Rectangle oval(Color fillColor, Color strokeColor, Double posX, Double posY, Double x, Double lineSize, Double opacity, Double blur, Double shadow){
Rectangle circle;
circle = new Rectangle(posX, posY, x, x);
circle.setStrokeWidth(lineSize);
circle.setFill(fillColor);
circle.setStroke(strokeColor);
circle.setArcHeight(100000000);
circle.setArcWidth(100000000);
circle.setOpacity(opacity/100);

return circle;
Expand All @@ -44,11 +82,13 @@ public Line line(Double lineSize, Color strokeColor, Double posX, Double posY, D
}

public Text text(String string, String textSize, Color textColor, String fontName, Double posX, Double posY, Double opacity){
Text text = new Text(posX, posY, string);
Text text = new Text(100, 100, string);
Double fs = Double.parseDouble(textSize);
text.setFont(new Font(fontName, fs));
text.setFill(textColor);



return text;
}

Expand Down
Binary file added src/sample/classes/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 36 additions & 8 deletions src/sample/controller/PikSixController.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javafx.scene.text.Font;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import jfxtras.labs.util.event.MouseControlUtil;
import sample.Credits;
import sample.classes.DragResizeMod;
import sample.classes.Tools;
Expand Down Expand Up @@ -103,6 +104,9 @@ public class PikSixController implements Initializable{
@FXML
private JFXButton btnAddShape = new JFXButton();

@FXML
private JFXButton btnSwapUp = new JFXButton();

// Var
public GraphicsContext gc;
private double positionX = 0;
Expand Down Expand Up @@ -130,6 +134,9 @@ public void initialize(URL location, ResourceBundle resources) {
spMain.setContent(mainPane);
spMain.setPrefSize(1100, 600);




btnResize.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
Expand Down Expand Up @@ -172,7 +179,10 @@ void cbShapesConfig(){
cbShapes.getItems().addAll("Rectangle", "Oval", "Line", "Text", "Image", "Background Color");
}

void cbFontStyleConfig() { cbbFontStyle.getItems().addAll(Font.getFontNames());}
void cbFontStyleConfig() {
cbbFontStyle.getItems().addAll(Font.getFontNames());
cbbFontStyle.setValue("Roboto");
}

public void draw(){
cbShapesSelect();
Expand All @@ -198,6 +208,24 @@ void cbShapesSelect(){
mainPane.getChildren().addAll(shape);
layerCount();
}
if(item == "Text") {
Shape shape;
System.out.println(item);
shape = tools.text(tfTextString.getText(), tfFontSize.getText(), cpTextColor.getValue(), cbbFontStyle.getValue().toString(), positionX, positionY, sldOpacity.getValue());
MouseControlUtil.makeDraggable(shape);

mainPane.getChildren().addAll(shape);
layerCount();
}
if(item == "Image") {
System.out.println(item);
Shape shape;
shape = tools.image(cpFillColor.getValue(), cpBorderColor.getValue(), 0.0, 0.0, 100.0, 100.0, sldBorderSize.getValue(), sldOpacity.getValue(), sldEffectBlur.getValue(), sldEffectShadow.getValue());
DragResizeMod.makeResizable(shape);
mainPane.getChildren().addAll(shape);
layerCount();
}

});

mainPane.setOnMouseClicked(event1 -> {
Expand All @@ -217,12 +245,13 @@ void cbShapesSelect(){
});

}
if(item == "Text") {
/*if(item == "Text") {
System.out.println(item);
mainPane.getChildren().addAll(tools.text(tfTextString.getText(), tfFontSize.getText(), cpTextColor.getValue(), cbbFontStyle.getValue().toString(), positionX, positionY, sldOpacity.getValue()));
layerCount();
}
}*/

if(item == "Background Color") {
System.out.println(item);
Expand Down Expand Up @@ -256,7 +285,7 @@ public void updateShape() {
Shape shape;

rotate = Double.parseDouble(tfShapeRotation.getText());

shape = (Shape) mainPane.getChildren().get(itemLayer);
shape.setRotate(rotate);
shape.setFill(cpFillColor.getValue());
Expand All @@ -279,10 +308,10 @@ public void saveFile(){
btnSave.setOnMouseClicked(event1 -> {
FileChooser fc = new FileChooser();
fc.setTitle("Save File");
fc.setInitialDirectory(new File("/home"));
fc.setInitialFileName("paint");
//fc.setInitialDirectory(new File("/home"));
fc.setInitialFileName("project");
fc.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("PNG File", "*.png"));

fc.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("JPEG File", "*.jpg"));
try{
File selectedFile = fc.showSaveDialog(new Stage());
if(selectedFile != null){
Expand Down Expand Up @@ -322,5 +351,4 @@ public void aboutWindow(){
Logger.getLogger(PikSixController.class.getName()).log(Level.SEVERE, null, ex);
}
}

}
12 changes: 12 additions & 0 deletions src/sample/style/Style.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,15 @@
-fx-background-radius: 5em;
}

.jfx-text-field {
-fx-background-color: #5f4b63;
-fx-font-size: 13px;
-fx-font-family: 'Roboto', sans-serif;
-fx-text-fill: white;
-fx-opacity: 1;
}


#spMain .content{
-fx-background-color: #5f4b63;
}
23 changes: 10 additions & 13 deletions src/sample/view/sample.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</Menu>
</menus>
</MenuBar>
<ToolBar prefHeight="40.0" prefWidth="200.0" styleClass="background">
<ToolBar prefHeight="40.0" prefWidth="200.0">
<items>
<JFXButton fx:id="btnSave" text="Save" />
<Separator orientation="VERTICAL">
Expand Down Expand Up @@ -75,7 +75,7 @@
<children>
<HBox spacing="10.0">
<children>
<Label text="Width" />
<Label text="Width " />
<JFXTextField fx:id="tfCanvaW" promptText="800" text="800" />
</children>
<VBox.margin>
Expand Down Expand Up @@ -147,7 +147,7 @@
<HBox spacing="10.0">
<children>
<Label text="Border Size" />
<JFXSlider fx:id="sldBorderSize" value="5.0" />
<JFXSlider fx:id="sldBorderSize" value="0.0" />
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
Expand Down Expand Up @@ -193,7 +193,7 @@
<HBox layoutX="10.0" layoutY="12.0" spacing="10.0">
<children>
<Label text="Text" />
<JFXTextField fx:id="tfTextString" />
<JFXTextField fx:id="tfTextString" promptText="hello world" />
</children>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
Expand Down Expand Up @@ -316,9 +316,6 @@
<VBox>
<children>
<HBox spacing="10.0">
<VBox.margin>
<Insets top="2.0" />
</VBox.margin>
<padding>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</padding>
Expand Down Expand Up @@ -359,15 +356,15 @@
</BorderPane.margin>
</VBox>
</right>
<center>
<Pane fx:id="pane" prefHeight="600.0" prefWidth="920.0" BorderPane.alignment="CENTER">
<left>
<HBox BorderPane.alignment="CENTER">
<children>
<ScrollPane fx:id="spMain" prefHeight="600.0" prefWidth="920.0">
<ScrollPane fx:id="spMain">
<content>
<Pane fx:id="tfPosY" prefHeight="600.0" prefWidth="920.0" BorderPane.alignment="CENTER" />
<Pane fx:id="tfPosY" style="-fx-background-color: back;" />
</content>
</ScrollPane>
</children>
</Pane>
</center>
</HBox>
</left>
</BorderPane>

0 comments on commit beb2bfe

Please sign in to comment.