modify QEFXGraphNote

This commit is contained in:
nisihara1 2017-07-11 23:17:28 +09:00
parent 395e406597
commit 3503ecbcd1
6 changed files with 174 additions and 28 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java8"/>
<classpathentry kind="lib" path="lib/exp4j-0.4.6.jar" sourcepath="lib/exp4j-0.4.6-sources.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/burai/lib/exp4j-0.4.6-javadoc.jar!/"/>

View File

@ -19,7 +19,10 @@ import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.gson.Gson;
@ -53,6 +56,8 @@ public class GraphProperty {
private List<SeriesProperty> seriesList;
private Map<String, Boolean> noteMap;
public GraphProperty() {
this.avail = true;
this.calcID = -1;
@ -68,6 +73,7 @@ public class GraphProperty {
this.yUpper = 0.0;
this.yTick = -1.0;
this.seriesList = null;
this.noteMap = null;
}
public int getCalcID() {
@ -198,6 +204,31 @@ public class GraphProperty {
this.seriesList.add(series);
}
public boolean isNoteMaximized(String key) {
if (key == null) {
return true;
}
if (this.noteMap == null || this.noteMap.isEmpty()) {
return true;
}
Boolean objMaximized = this.noteMap.get(key);
return objMaximized == null ? true : objMaximized.booleanValue();
}
public void setNoteMaximized(String key, boolean maximized) {
if (key == null) {
return;
}
if (this.noteMap == null) {
this.noteMap = new HashMap<String, Boolean>();
}
this.noteMap.put(key, maximized);
}
@Override
public String toString() {
return this.title;
@ -271,6 +302,22 @@ public class GraphProperty {
series1.setWithSymbol(series2.isWithSymbol());
}
}
if (obj.noteMap != null && !(obj.noteMap.isEmpty())) {
if (this.noteMap == null) {
this.noteMap = new HashMap<String, Boolean>();
}
Set<String> keys = obj.noteMap.keySet();
if (keys != null) {
for (String key : keys) {
Boolean value = key == null ? null : obj.noteMap.get(key);
if (value != null) {
this.noteMap.put(key, value);
}
}
}
}
}
}

View File

@ -15,6 +15,10 @@ import java.net.URL;
import java.util.ResourceBundle;
import java.util.Set;
import burai.app.project.QEFXProjectController;
import burai.app.project.viewer.result.QEFXResultViewerController;
import burai.app.project.viewer.result.graph.tools.QEFXGraphLegend;
import burai.app.project.viewer.result.graph.tools.QEFXGraphNote;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
@ -29,10 +33,6 @@ import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import burai.app.project.QEFXProjectController;
import burai.app.project.viewer.result.QEFXResultViewerController;
import burai.app.project.viewer.result.graph.tools.QEFXGraphLegend;
import burai.app.project.viewer.result.graph.tools.QEFXGraphNote;
public abstract class QEFXGraphViewerController extends QEFXResultViewerController {
@ -136,7 +136,29 @@ public abstract class QEFXGraphViewerController extends QEFXResultViewerControll
if (this.projectController != null) {
try {
QEFXGraphNote note = new QEFXGraphNote(this.projectController, node);
boolean maximized = true;
if (this.property != null && pos != null) {
maximized = this.property.isNoteMaximized(pos.toString());
}
QEFXGraphNote note = new QEFXGraphNote(this.projectController, node, maximized);
note.setOnNoteMaximized(maximized_ -> {
if (this.property == null || pos == null) {
return;
}
this.property.setNoteMaximized(pos.toString(), maximized_);
if (this.propertyFile != null) {
try {
this.property.writeFile(this.propertyFile);
} catch (IOException e) {
e.printStackTrace();
}
}
});
Node noteNode = note.getNode();
if (noteNode != null) {
if (pos != null) {

View File

@ -0,0 +1,16 @@
/*
* Copyright (C) 2017 Satomichi Nishihara
*
* This file is distributed under the terms of the
* GNU General Public License. See the file `LICENSE'
* in the root directory of the present distribution,
* or http://www.gnu.org/copyleft/gpl.txt .
*/
package burai.app.project.viewer.result.graph.tools;
public interface NoteMaximized {
public abstract void onNoteMaximized(boolean maximized);
}

View File

@ -11,14 +11,32 @@ package burai.app.project.viewer.result.graph.tools;
import java.io.IOException;
import javafx.scene.Node;
import burai.app.QEFXAppComponent;
import burai.app.project.QEFXProjectController;
import javafx.scene.Node;
public class QEFXGraphNote extends QEFXAppComponent<QEFXGraphNoteController> {
public QEFXGraphNote(QEFXProjectController projectController, Node content) throws IOException {
super("QEFXGraphNote.fxml", new QEFXGraphNoteController(projectController, content));
public QEFXGraphNote(QEFXProjectController projectController, Node content, boolean initMaximized) throws IOException {
super("QEFXGraphNote.fxml", new QEFXGraphNoteController(projectController, content, initMaximized));
}
public void setOnNoteMaximized(NoteMaximized onNoteMaximized) {
if (this.controller != null) {
this.controller.setOnNoteMaximized(onNoteMaximized);
}
}
public void minimize() {
if (this.controller != null) {
this.controller.minimize();
}
}
public void maximize() {
if (this.controller != null) {
this.controller.maximize();
}
}
}

View File

@ -12,6 +12,10 @@ package burai.app.project.viewer.result.graph.tools;
import java.net.URL;
import java.util.ResourceBundle;
import burai.app.QEFXAppController;
import burai.app.project.QEFXProjectController;
import burai.com.graphic.svg.SVGLibrary;
import burai.com.graphic.svg.SVGLibrary.SVGData;
import javafx.fxml.FXML;
import javafx.geometry.Insets;
import javafx.scene.Group;
@ -21,10 +25,6 @@ import javafx.scene.control.ToolBar;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import burai.app.QEFXAppController;
import burai.app.project.QEFXProjectController;
import burai.com.graphic.svg.SVGLibrary;
import burai.com.graphic.svg.SVGLibrary.SVGData;
public class QEFXGraphNoteController extends QEFXAppController {
@ -53,7 +53,13 @@ public class QEFXGraphNoteController extends QEFXAppController {
private Button maxButton;
public QEFXGraphNoteController(QEFXProjectController projectController, Node content) {
private boolean maximized;
private boolean initMaximized;
private NoteMaximized onNoteMaximized;
public QEFXGraphNoteController(QEFXProjectController projectController, Node content, boolean initMaximized) {
super(projectController == null ? null : projectController.getMainController());
if (projectController == null) {
@ -68,6 +74,49 @@ public class QEFXGraphNoteController extends QEFXAppController {
this.content = content;
this.maxButton = null;
this.maximized = true;
this.initMaximized = initMaximized;
this.onNoteMaximized = null;
}
public void setOnNoteMaximized(NoteMaximized onNoteMaximized) {
this.onNoteMaximized = onNoteMaximized;
}
public void minimize() {
if (!this.maximized) {
return;
}
if (this.baseGroup != null && this.maxButton != null) {
ToolBar toolBar = new ToolBar(this.maxButton);
toolBar.getStyleClass().add(NOTE_CLASS);
this.baseGroup.getChildren().clear();
this.baseGroup.getChildren().add(toolBar);
this.maximized = false;
if (this.onNoteMaximized != null) {
this.onNoteMaximized.onNoteMaximized(false);
}
}
}
public void maximize() {
if (this.maximized) {
return;
}
if (this.baseGroup != null && this.basePane != null) {
this.baseGroup.getChildren().clear();
this.baseGroup.getChildren().add(this.basePane);
this.maximized = true;
if (this.onNoteMaximized != null) {
this.onNoteMaximized.onNoteMaximized(true);
}
}
}
@Override
@ -77,6 +126,12 @@ public class QEFXGraphNoteController extends QEFXAppController {
this.setupScreenButton();
this.setupMinButton();
this.setupMaxButton();
if (this.initMaximized) {
this.maximize();
} else {
this.minimize();
}
}
private void setupBaseGroup() {
@ -124,14 +179,7 @@ public class QEFXGraphNoteController extends QEFXAppController {
this.minButton.setTooltip(new Tooltip("minimize"));
this.minButton.setOnAction(event -> {
if (this.baseGroup != null && this.maxButton != null) {
ToolBar toolBar = new ToolBar(this.maxButton);
toolBar.getStyleClass().add(NOTE_CLASS);
this.baseGroup.getChildren().clear();
this.baseGroup.getChildren().add(toolBar);
}
});
this.minButton.setOnAction(event -> this.minimize());
}
private void setupMaxButton() {
@ -144,11 +192,6 @@ public class QEFXGraphNoteController extends QEFXAppController {
this.maxButton.setTooltip(new Tooltip("maximize"));
this.maxButton.setOnAction(event -> {
if (this.baseGroup != null && this.basePane != null) {
this.baseGroup.getChildren().clear();
this.baseGroup.getChildren().add(this.basePane);
}
});
this.maxButton.setOnAction(event -> this.maximize());
}
}