-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #273 from ProgrammingLife2017/MiniMap
Mini map
- Loading branch information
Showing
4 changed files
with
172 additions
and
68 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
src/main/java/programminglife/controller/MiniMapController.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 programminglife.controller; | ||
|
||
import javafx.scene.canvas.Canvas; | ||
import javafx.scene.canvas.GraphicsContext; | ||
import javafx.scene.paint.Color; | ||
import programminglife.gui.controller.GuiController; | ||
|
||
/** | ||
* Controller that shows a MiniMap in the gui. | ||
*/ | ||
public class MiniMapController { | ||
|
||
private GuiController guiController; | ||
private Canvas miniMap; | ||
private int size; | ||
|
||
private boolean visible = false; | ||
|
||
/** | ||
* Constructor for the miniMap. | ||
* @param miniMap Canvas of the miniMap to be used. | ||
* @param size int Size of the graph. | ||
*/ | ||
public MiniMapController(Canvas miniMap, int size) { | ||
this.miniMap = miniMap; | ||
miniMap.setVisible(visible); | ||
this.size = size; | ||
} | ||
|
||
/** | ||
* Draws the MiniMap on the screen. | ||
*/ | ||
private void drawMiniMap() { | ||
GraphicsContext gc = miniMap.getGraphicsContext2D(); | ||
gc.setFill(Color.LIGHTGRAY); | ||
gc.fillRect(0, 0, miniMap.getWidth(), 50); | ||
|
||
gc.setStroke(Color.BLACK); | ||
gc.setLineWidth(2); | ||
gc.strokeLine(0, 25, miniMap.getWidth(), 25); | ||
} | ||
|
||
/** | ||
* Toggle the visibility of the MiniMap. | ||
*/ | ||
public void toggleVisibility() { | ||
visible = !visible; | ||
this.miniMap.setVisible(visible); | ||
if (visible) { | ||
drawMiniMap(); | ||
} | ||
} | ||
|
||
/** | ||
* Shows the position of where you are in the graph (on the screen). | ||
* It does not handle panning as of now! | ||
* @param centerNode int of the centernode currently at. | ||
*/ | ||
public void showPosition(int centerNode) { | ||
GraphicsContext gc = miniMap.getGraphicsContext2D(); | ||
gc.clearRect(0, 0, miniMap.getWidth(), miniMap.getHeight()); | ||
drawMiniMap(); | ||
gc.setFill(Color.RED); | ||
System.out.println(centerNode); | ||
System.out.println(size); | ||
System.out.println(miniMap.getWidth()); | ||
gc.fillOval((centerNode / (double) size) * miniMap.getWidth(), 20, 10, 10); | ||
} | ||
|
||
/** | ||
* Sets the guicontroller for controlling the menu. | ||
* @param guiController The gui controller | ||
*/ | ||
public void setGuiController(GuiController guiController) { | ||
this.guiController = guiController; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,70 +1,84 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!--suppress ALL --> | ||
|
||
<?import java.lang.*?> | ||
<?import javafx.scene.*?> | ||
<?import javafx.scene.control.*?> | ||
<?import javafx.scene.layout.*?> | ||
<?import javafx.scene.Group?> | ||
<?import javafx.scene.control.Button?> | ||
<?import javafx.scene.control.Menu?> | ||
<?import javafx.scene.control.MenuBar?> | ||
<?import javafx.scene.control.MenuItem?> | ||
<?import javafx.scene.control.ProgressBar?> | ||
<?import javafx.scene.control.RadioMenuItem?> | ||
<?import javafx.scene.control.SeparatorMenuItem?> | ||
<?import javafx.scene.control.SplitPane?> | ||
<?import javafx.scene.control.Tab?> | ||
<?import javafx.scene.control.TabPane?> | ||
<?import javafx.scene.control.TextField?> | ||
<?import javafx.scene.layout.AnchorPane?> | ||
<?import javafx.scene.layout.VBox?> | ||
|
||
<!--suppress ALL --> | ||
<?import javafx.scene.layout.*?> | ||
|
||
<AnchorPane prefHeight="500.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="programminglife.gui.controller.GuiController"> | ||
<MenuBar AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> | ||
<Menu fx:id="menuFile" mnemonicParsing="false" text="File"> | ||
<MenuItem fx:id="btnOpenGFA" mnemonicParsing="false" text="Open GFA" /> | ||
<MenuItem fx:id="btnOpenGFF" mnemonicParsing="false" text="Open GFF" /> | ||
<Menu fx:id="menuRecent" mnemonicParsing="false" text="Open Recent GFA" /> | ||
<SeparatorMenuItem mnemonicParsing="false" /> | ||
<RadioMenuItem fx:id="btnToggle" mnemonicParsing="false" text="Toggle Console" /> | ||
<MenuItem fx:id="btnQuit" mnemonicParsing="false" text="Quit" /> | ||
</Menu> | ||
<Menu fx:id="menuHelp" mnemonicParsing="false" text="Help"> | ||
<MenuItem fx:id="btnAbout" mnemonicParsing="false" text="About" /> | ||
<MenuItem fx:id="btnInstructions" mnemonicParsing="false" text="Instructions" /> | ||
</Menu> | ||
<Menu fx:id="menuBookmark" mnemonicParsing="false" text="Bookmarks"> | ||
<MenuItem fx:id="btnBookmarks" mnemonicParsing="false" text="Bookmarks" /> | ||
</Menu> | ||
</MenuBar> | ||
<SplitPane dividerPositions="0.14, 1.0" layoutY="29.0" prefHeight="200.0" prefWidth="500.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="29.0"> | ||
<AnchorPane fx:id="anchorLeftControlPanel" maxWidth="140.0" minHeight="0.0" minWidth="140.0" prefHeight="800.0" prefWidth="100.0" SplitPane.resizableWithParent="false"> | ||
<Button fx:id="btnZoomReset" layoutX="12.0" layoutY="20.0" minWidth="100.0" mnemonicParsing="false" text="Reset Zoom" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<Button fx:id="btnTranslateReset" layoutX="12.0" layoutY="50.0" minWidth="100.0" mnemonicParsing="false" text="Reset X/Y" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<TextField text="Center Node:" layoutX="20.0" layoutY="85.0" editable="false" style="-fx-text-box-border: transparent;-fx-background-color: none; -fx-background-insets: 0; -fx-padding: 1 3 1 3; -fx-focus-color: transparent; -fx-faint-focus-color: transparent;"/> | ||
<TextField fx:id="txtCenterNode" layoutX="20.0" layoutY="100.0" minWidth="100.0" promptText="Origin node" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<TextField text="Radius:" layoutX="20.0" layoutY="130.0" editable="false" style="-fx-text-box-border: transparent;-fx-background-color: none; -fx-background-insets: 0; -fx-padding: 1 3 1 3; -fx-focus-color: transparent; -fx-faint-focus-color: transparent;"/> | ||
<TextField fx:id="txtMaxDrawDepth" layoutX="20.0" layoutY="145.0" minWidth="100.0" promptText="Max depth" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<Button fx:id="btnDraw" layoutX="27.0" layoutY="180.0" minWidth="100.0" mnemonicParsing="false" text="Draw" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<Button fx:id="btnDrawRandom" layoutX="20.0" layoutY="210.0" minWidth="100.0" mnemonicParsing="false" text="Surprise me!" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<Button fx:id="btnBookmark" layoutX="20.0" layoutY="240.0" minWidth="100.0" mnemonicParsing="false" text="Bookmark" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
</AnchorPane> | ||
<AnchorPane fx:id="anchorGraphPanel" minHeight="200" minWidth="200" prefHeight="Infinity" prefWidth="Infinity"> | ||
<Group fx:id="grpDrawArea" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> | ||
<ProgressBar fx:id="progressBar" minHeight="18.0" minWidth="100.0" progress="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" /> | ||
</AnchorPane> | ||
<AnchorPane maxWidth="500.0" minWidth="140.0" prefHeight="800.0" prefWidth="Infinity"> | ||
<TabPane maxWidth="500.0" tabClosingPolicy="UNAVAILABLE" tabMaxHeight="100.0" tabMaxWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> | ||
<Tab text="Graph Info"> | ||
<AnchorPane fx:id="anchorGraphInfo" minWidth="50.0"> | ||
<Button fx:id="btnClipboard" layoutX="15.0" layoutY="15.0" mnemonicParsing="false" text="Copy to clipboard" /> | ||
<Button fx:id="btnClipboard2" layoutX="255.0" layoutY="15.0" mnemonicParsing="false" text="Copy to clipboard" /> | ||
</AnchorPane> | ||
</Tab> | ||
<Tab fx:id="searchTab" text="Search / Highlight" /> | ||
</TabPane> | ||
</AnchorPane> | ||
</SplitPane> | ||
<?import javafx.scene.canvas.Canvas?> | ||
<AnchorPane prefHeight="500.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="programminglife.gui.controller.GuiController"> | ||
<children> | ||
<MenuBar AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> | ||
<menus> | ||
<Menu fx:id="menuFile" mnemonicParsing="false" text="File"> | ||
<items> | ||
<MenuItem fx:id="btnOpenGFA" mnemonicParsing="false" text="Open GFA" /> | ||
<MenuItem fx:id="btnOpenGFF" mnemonicParsing="false" text="Open GFF" /> | ||
<Menu fx:id="menuRecent" mnemonicParsing="false" text="Open Recent GFA" /> | ||
<SeparatorMenuItem mnemonicParsing="false" /> | ||
<RadioMenuItem fx:id="btnToggle" mnemonicParsing="false" text="Toggle Console" /> | ||
<RadioMenuItem fx:id="btnMiniMap" mnemonicParsing="false" text="Toggle MiniMap" /> | ||
<MenuItem fx:id="btnQuit" mnemonicParsing="false" text="Quit" /> | ||
</items> | ||
</Menu> | ||
<Menu fx:id="menuHelp" mnemonicParsing="false" text="Help"> | ||
<items> | ||
<MenuItem fx:id="btnAbout" mnemonicParsing="false" text="About" /> | ||
<MenuItem fx:id="btnInstructions" mnemonicParsing="false" text="Instructions" /> | ||
</items> | ||
</Menu> | ||
<Menu fx:id="menuBookmark" mnemonicParsing="false" text="Bookmarks"> | ||
<items> | ||
<MenuItem fx:id="btnBookmarks" mnemonicParsing="false" text="Bookmarks" /> | ||
</items> | ||
</Menu> | ||
</menus> | ||
</MenuBar> | ||
<SplitPane dividerPositions="0.14, 1.0" layoutY="29.0" prefHeight="200.0" prefWidth="500.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="29.0"> | ||
<items> | ||
<AnchorPane fx:id="anchorLeftControlPanel" maxWidth="140.0" minHeight="0.0" minWidth="140.0" prefHeight="800.0" prefWidth="100.0" SplitPane.resizableWithParent="false"> | ||
<children> | ||
<Button fx:id="btnZoomReset" layoutX="12.0" layoutY="20.0" minWidth="100.0" mnemonicParsing="false" text="Reset Zoom" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<Button fx:id="btnTranslateReset" layoutX="12.0" layoutY="50.0" minWidth="100.0" mnemonicParsing="false" text="Reset X/Y" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<TextField editable="false" layoutX="20.0" layoutY="85.0" style="-fx-text-box-border: transparent;-fx-background-color: none; -fx-background-insets: 0; -fx-padding: 1 3 1 3; -fx-focus-color: transparent; -fx-faint-focus-color: transparent;" text="Center Node:" /> | ||
<TextField fx:id="txtCenterNode" layoutX="20.0" layoutY="100.0" minWidth="100.0" promptText="Origin node" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<TextField editable="false" layoutX="20.0" layoutY="130.0" style="-fx-text-box-border: transparent;-fx-background-color: none; -fx-background-insets: 0; -fx-padding: 1 3 1 3; -fx-focus-color: transparent; -fx-faint-focus-color: transparent;" text="Radius:" /> | ||
<TextField fx:id="txtMaxDrawDepth" layoutX="20.0" layoutY="145.0" minWidth="100.0" promptText="Max depth" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<Button fx:id="btnDraw" layoutX="27.0" layoutY="180.0" minWidth="100.0" mnemonicParsing="false" text="Draw" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<Button fx:id="btnDrawRandom" layoutX="20.0" layoutY="210.0" minWidth="100.0" mnemonicParsing="false" text="Surprise me!" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
<Button fx:id="btnBookmark" layoutX="20.0" layoutY="240.0" minWidth="100.0" mnemonicParsing="false" text="Bookmark" AnchorPane.leftAnchor="20.0" AnchorPane.rightAnchor="20.0" /> | ||
</children> | ||
</AnchorPane> | ||
<AnchorPane fx:id="anchorGraphPanel" minHeight="200" minWidth="200" prefHeight="Infinity" prefWidth="Infinity"> | ||
<children> | ||
<Canvas fx:id="miniMap" height="100" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" /> | ||
<Group fx:id="grpDrawArea" AnchorPane.bottomAnchor="100.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" /> | ||
<ProgressBar fx:id="progressBar" minHeight="18.0" minWidth="100.0" progress="0.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" /> | ||
</children> | ||
</AnchorPane> | ||
<AnchorPane maxWidth="500.0" minWidth="140.0" prefHeight="800.0" prefWidth="Infinity"> | ||
<children> | ||
<TabPane maxWidth="500.0" tabClosingPolicy="UNAVAILABLE" tabMaxHeight="100.0" tabMaxWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> | ||
<tabs> | ||
<Tab text="Graph Info"> | ||
<content> | ||
<AnchorPane fx:id="anchorGraphInfo" minWidth="50.0"> | ||
<children> | ||
<Button fx:id="btnClipboard" layoutX="15.0" layoutY="15.0" mnemonicParsing="false" text="Copy to clipboard" /> | ||
<Button fx:id="btnClipboard2" layoutX="255.0" layoutY="15.0" mnemonicParsing="false" text="Copy to clipboard" /> | ||
</children> | ||
</AnchorPane> | ||
</content> | ||
</Tab> | ||
<Tab fx:id="searchTab" text="Search / Highlight" /> | ||
</tabs> | ||
</TabPane> | ||
</children> | ||
</AnchorPane> | ||
</items> | ||
</SplitPane> | ||
</children> | ||
</AnchorPane> |