Skip to content

Commit

Permalink
fix: fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikRevich committed Dec 13, 2023
1 parent bd471a8 commit 1c053b3
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 65 deletions.
2 changes: 2 additions & 0 deletions gui/src/main/java/com/resourcetracker/GUI.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.resourcetracker;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableAsync;

@EnableAsync
@SpringBootApplication
public class GUI {
public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ public static void switchScene(Scene prev, Scene next) {
((Stage) prev.getWindow()).setScene(next);
}

//
// public static void switchStage(Stage prev, Stage next) {
// prev.close();
// next.show();
// }

/** Retrieves */
public static Point2D getCentralPoint(Double width, Double height) {
Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ public GraphVisualizer(
} catch (URISyntaxException e) {
throw new SmartGraphCssFileNotFoundException(e.getMessage());
}
//
// ElementStorage.setElement(
// id,
// new SmartGraphPanel<>(
// g, smartGraphProperties, strategy, smartGraphCssFileLocationURI));



ElementStorage.setElement(
id,
new SmartGraphPanel<>(
g, smartGraphProperties, strategy, smartGraphCssFileLocationURI));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.resourcetracker.service.element.storage.ElementStorage;
import com.resourcetracker.service.event.state.LocalState;
import javafx.application.Platform;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.SplitPane;
import javafx.scene.control.Tooltip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class ConnectionStatusHBox implements IElement<HBox> {

public ConnectionStatusHBox(SplitPane connectionStatusImage) {
HBox hBox = new HBox(connectionStatusImage);
hBox.setAlignment(Pos.CENTER_RIGHT);
hBox.setAlignment(Pos.TOP_RIGHT);

ElementStorage.setElement(id, hBox);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.resourcetracker.service.element.layout.common;

import com.resourcetracker.service.element.IElement;
import com.resourcetracker.service.element.IElementResizable;
import com.resourcetracker.service.element.storage.ElementStorage;
import javafx.scene.Node;
import javafx.scene.layout.HBox;

import java.util.UUID;

public class LandingHBox implements IElementResizable, IElement<HBox> {
UUID id = UUID.randomUUID();

public LandingHBox(Node... elements) {
HBox hbox = new HBox(20, elements);

ElementStorage.setElement(id, hbox);
}

/**
* @return
*/
@Override
public HBox getContent() {
return ElementStorage.getElement(id);
}

/**
*
*/
@Override
public void handlePrefWidth() {

}

/**
*
*/
@Override
public void handlePrefHeight() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,59 @@
import com.resourcetracker.service.element.IElementResizable;
import com.resourcetracker.service.element.button.BasicButton;
import com.resourcetracker.service.element.common.WindowHelper;
import com.resourcetracker.service.element.graph.GraphVisualizer;
import com.resourcetracker.service.element.image.view.ConnectionStatusImageView;
import com.resourcetracker.service.element.layout.common.ButtonVBox;
import com.resourcetracker.service.element.layout.common.ConnectionStatusHBox;
import com.resourcetracker.service.element.layout.common.LandingHBox;
import com.resourcetracker.service.element.menu.TabMenuBar;
import com.resourcetracker.service.element.scene.main.DeploymentDetailsScene;
import com.resourcetracker.service.element.scene.main.DeploymentScene;
import com.resourcetracker.service.element.scene.main.StartScene;
import com.resourcetracker.service.element.scene.settings.SettingsLanguagesScene;
import com.resourcetracker.service.element.stage.SettingsStage;
import com.resourcetracker.service.element.storage.ElementStorage;
import com.resourcetracker.service.event.state.LocalState;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.RowConstraints;
import org.apache.logging.log4j.core.tools.picocli.CommandLine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.awt.*;
import java.util.UUID;

@Service
public class StartSceneLayout implements IElementResizable, IElement<GridPane> {
UUID id = UUID.randomUUID();

@Lazy
@Autowired
private StartScene startScene;

@Lazy
@Autowired
private DeploymentScene deploymentScene;

@Lazy
@Autowired
private DeploymentDetailsScene deploymentDetailsScene;

public StartSceneLayout(
@Autowired PropertiesEntity properties,
@Autowired SettingsLanguagesScene settingsLanguagesScene,
@Autowired ConnectionStatusImageView connectionStatusImageView
@Autowired SettingsStage settingsStage,
@Autowired ConnectionStatusImageView connectionStatusImageView,
@Autowired GraphVisualizer graphVisualizer
) {
// @Autowired DeploymentScene deploymentScene,
// @Autowired DeploymentDetailsScene deploymentDetailsScene,
// @Autowired SettingsLanguagesScene settingsLanguagesScene,


GridPane grid = new GridPane();
grid.setVgap(20);

grid.setMinWidth(400);
grid.setGridLinesVisible(true);

ConnectionStatusHBox connectionStatusHBox = new ConnectionStatusHBox(
Expand All @@ -48,28 +68,49 @@ public StartSceneLayout(
new BasicButton(
"Start",
properties,
() -> {
WindowHelper.switchScene(getContent().getScene(), settingsLanguagesScene.getContent());
System.out.println("it start");
})
() -> WindowHelper.switchScene(getContent().getScene(), startScene.getContent()))
.getContent(),
new BasicButton(
"Deployment",
properties,
() -> {
System.out.println("it deployment");
})
() -> WindowHelper.switchScene(getContent().getScene(), deploymentScene.getContent()))
.getContent(),
new BasicButton(
"Settings",
properties,
() -> {
System.out.println("it settings");
})
() -> settingsStage.getContent().show())
.getContent());

grid.addRow(0, connectionStatusHBox.getContent());
grid.addRow(1, buttonVBox.getContent());
// graphVisualizer.getContent().setTranslateX(100);
// graphVisualizer.getContent().setTranslateY(100);

Label label = new Label("Your long text here");
label.setAlignment(Pos.CENTER);
label.setMaxWidth(180);
label.setWrapText(true);

LandingHBox landingHBox = new LandingHBox(
buttonVBox.getContent(), label);

ColumnConstraints column1 = new ColumnConstraints();
column1.setHgrow(Priority.ALWAYS);

grid.getColumnConstraints().add(0, column1);

RowConstraints row1 = new RowConstraints();
row1.setPercentHeight(5);
RowConstraints row2 = new RowConstraints();
row2.setPercentHeight(70);

grid.getRowConstraints().add(0, row1);
grid.getRowConstraints().add(1, row2);

grid.addColumn(0, connectionStatusHBox.getContent(),
landingHBox.getContent());

// grid.addRow(0,
// );
// grid.addRow(1, );
//
// // GraphVisualizer graphVisualizer = new GraphVisualizer();
//
Expand Down Expand Up @@ -98,15 +139,14 @@ public GridPane getContent() {
*/
@Override
public void handlePrefWidth() {
System.out.println(LocalState.getWindowWidth());

getContent().setMinWidth(LocalState.getWindowWidth());
}

/**
*
*/
@Override
public void handlePrefHeight() {
System.out.println(LocalState.getWindowHeight());
getContent().setMinHeight(LocalState.getWindowHeight());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,31 @@
import com.resourcetracker.service.element.common.WindowHelper;
import com.resourcetracker.service.element.scene.main.StartScene;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;

import com.resourcetracker.service.element.storage.ElementStorage;
import com.resourcetracker.service.event.state.LocalState;
import com.resourcetracker.service.event.state.payload.WindowHeightUpdateEvent;
import com.resourcetracker.service.event.state.payload.WindowWidthUpdateEvent;
import jakarta.annotation.PostConstruct;
import javafx.application.Platform;
import javafx.geometry.Point2D;
import javafx.geometry.Rectangle2D;
import javafx.stage.Stage;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.core.Local;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/** MainStage represents main window. */
@Service
public class MainStage implements IElement<Stage> {
UUID id = UUID.randomUUID();

public MainStage(
public MainStage(
@Autowired PropertiesEntity properties,
@Autowired StartScene startScene,
@Autowired ApplicationEventPublisher applicationEventPublisher) {
Expand All @@ -31,7 +38,7 @@ public MainStage(
Stage mainStage = new Stage();
mainStage.setTitle(properties.getWindowMainName());

Rectangle2D window =
Rectangle2D window =
WindowHelper.getSizeWithScale(
properties.getWindowMainScaleWidth(), properties.getWindowMainScaleHeight());
mainStage.setWidth(window.getWidth());
Expand All @@ -49,13 +56,17 @@ public MainStage(
mainStage
.widthProperty()
.addListener(
(obs, oldVal, newVal) -> applicationEventPublisher.publishEvent(
new WindowWidthUpdateEvent(newVal.doubleValue())));
(obs, oldVal, newVal) -> {
applicationEventPublisher.publishEvent(
new WindowWidthUpdateEvent(newVal.doubleValue()));
});
mainStage
.heightProperty()
.addListener(
(obs, oldVal, newVal) -> applicationEventPublisher.publishEvent(
new WindowHeightUpdateEvent(newVal.doubleValue())));
(obs, oldVal, newVal) -> {
applicationEventPublisher.publishEvent(
new WindowHeightUpdateEvent(newVal.doubleValue()));
});

ElementStorage.setElement(id, mainStage);
});
Expand Down
Loading

0 comments on commit 1c053b3

Please sign in to comment.