GithubHelp home page GithubHelp logo

anchorfx's Introduction

Anchorfx logo

Docking framework for JavaFX platform

Anchorfx logo

AnchorFX is a gratis and open source library for JavaFX to create graphical interfaces with docking features

Anchorfx logo

AnchorFX and its source code is licensed under the GNU Lesser General Public License version 3 and you can make adaptations of this work

Features

  • Stations and sub stations support
  • Dockable and floatable panels
  • Splitter and Tabs containers support
  • CSS styling

Usage

Create a DockStation
DockStation station = AnchorageSystem.createStation();

Once created the station, we can create the panels and hook them to the station

Create a DockNode
Pane myPanel...
DockNode dockNode = AnchorageSystem.createDock("My Title", myPanel);
dockNode.dock(station, DockNode.DOCK_POSITION.CENTER);

A DockNode is the window built around your panel. This window has a title and an icon and it can be defined as:

  • Closeable
  • Resizable
  • Maximizable
  • Floatable

If we want to create a node that can not be closed, we will write

dockNode.closeableProperty().set(false);
Get ower DockNode from content panel

To know the reference of DockNode that contains your panel, implements the DockNodeCreationListener interface in your panel.

class MyPanel extends Pane implements DockNodeCreationListener {
 
    @Override
    public void onDockNodeCreated(DockNode node) {
         // now you can work with events of your DockNode 
    }

}
Add a DockNode to a Dockstation

To be visible, a node must be associated with a station. To do this procedure, we use the function dock (...) of DockNode

dockNode.dock(station, DockNode.DOCK_POSITION.CENTER);

In this case, the node will be added to the station in a central position. When a station is empty, the location will always be central, otherwise, will be taken the position provided and will be changed the layout

You may also add a node by specifying the percentage of placement of the divider. This percentage is only effective if the position is provided different from the central

dockNode.dock(station, DockNode.DOCK_POSITION.CENTER, 0.8);

Adding a node over another specific node

AnchorFX provides the possibility to add a node in a generic position respect to another node already present in the station. This feature lets you design a custom layout when your application starts

dockNode.dock(otherNode, DockNode.DOCK_POSITION.CENTER);
Create a DockSubStation

A Dock SubStation is a station that also has the functionality of DockNode The nodes that are associated with a DockSubStation can only be moved within the DockSubStation associated.

 DockSubStation subStation = AnchorageSystem.createSubStation(station, "SubStation");
 dockSubNode.dock(subStation, DockNode.DOCK_POSITION.CENTER);
 
 subStation.dock(station, DockNode.DOCK_POSITION.LEFT,0.7);
Styling with AnchorFX.css

The file AnchorFX.css located within resource, defines a simple default style

.docknode-title-bar {
   -fx-background-color: rgb(100,100,100);
}

.docknode-title-text{
   -fx-text-fill: rgb(255,255,255);
}

.docknode-content-panel{
   -fx-background-color: rgb(100,100,100);
   -fx-padding: 0
}

.docknode-floating-stack-container-panel {
   -fx-background-color: rgb(100,100,100);
   -fx-padding: 4
}

.docknode-split-pane {  
   -fx-padding: 0;  
} 

.docknode-split-pane *.split-pane-divider {  
   -fx-padding: 2;  
   -fx-border-color:transparent;
   -fx-color: darkgray;
} 

.docknode-tab-panel{
   -fx-padding: 0;
}

.docknode-command-button{
   -fx-background-color:transparent;
   -fx-background-radius: 0,0,0;
}

.docknode-command-button:hover{
   -fx-background-color:darkgray;
}

.docknode-command-button:pressed{
   -fx-background-color:darkgray;
}

.docknode-command-button:focused{
   -fx-background-color:transparent;
}

.docknode-command-button-close{
   -fx-background-color:transparent;
   -fx-background-radius: 0,0,0;
}

.docknode-command-button-close:pressed{
   -fx-background-color:red;
}

.docknode-command-button-close:hover{
   -fx-background-color:red;
}

.docknode-command-button-close:focused{
   -fx-background-color:transparent;
} 

.station {
   -fx-background-color: rgb(0,0,0);
   -fx-padding: 0
}

.substation-title-bar {
   -fx-background-color: rgb(0,0,0);
}

.substation-title-text{
   -fx-text-fill: rgb(255,255,255);
}

.dockzone-circle-container-selectors {
   -fx-fill: rgba(0,0,0,0.7);
}

.dockzone-circle-selector {
   -fx-fill: rgba(0,0,0,0.8);
}

.dockzone-rectangle-preview {
   -fx-fill: rgba(63,138,163,0.8);
}

Explore the examples on test package

The examples will use the functionality described

  • AnchorFX_test.java
  • AnchorFX_substations.java
  • AnchorFX_settings.java
  • AnchorFX_events.java
  • AnchorFX_CommonStations.java

anchorfx's People

Contributors

aalmiray avatar alexbodogit avatar eugener avatar ruckc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anchorfx's Issues

3rd and subsequent DockPanes added to tabber do not get undocked

When adding more than 2 DockPanes to a site (a dock container?), the OnCloseRequest handler is not configured. As a result, they are not undocked when removed using the X on the tab (using the close button on the node still works). This behavior is inconsistent with the first 2 nodes added into the tabber.

When I say "they are not undocked", they do visually disappear. The CloseRequestHandler is not called and undock() is not called, leaving the DockPane (and my code) in a confused state.

It seems to me that DockCommons.createTabber() should create the tabber and then call putDock() for each of the two nodes. putDock() should register the OnCloseRequest handler on each tab. This would ensure that tabs are created and configured consistently, if they are the first or Nth tabs added.

I can take a shot at creating a fix for this, if you'd like. It's diving a little deeper than I expected, though, so I thought I'd check with you first.

TIA!
Chris

Percentage is not correct

Here is my code
`DockStation dockStation = AnchorageSystem.createStation();
DockNode dock1 = AnchorageSystem.createDock("DOCK 1", new BorderPane());
DockNode dock2 = AnchorageSystem.createDock("DOCK 2", new BorderPane());
DockNode dock3 = AnchorageSystem.createDock("DOCK 3", new BorderPane());
DockNode dock4 = AnchorageSystem.createDock("DOCK 4", nnew BorderPane());
DockNode dock5 = AnchorageSystem.createDock("DOCK 5", new BorderPane());

dock1.dock(dockStation, DockNode.DockPosition.CENTER);
dock2.dock(dock1, DockNode.DockPosition.RIGHT,0.25);
dock3.dock(dockStation, DockNode.DockPosition.RIGHT,0.75);
dock4.dock(dock2, DockNode.DockPosition.BOTTOM,0.75);
dock5.dock(dock1, DockNode.DockPosition.BOTTOM,0.5);`

When I use only dock1->dock3, layout will have 3 column with percent was 25% 50% 25%
But when I use dock1->dock5 layout will change to 3 column with percent was 37.5% 37.5% 25%
Percent is not correct.
Please check this problem,

How to installer a 'placeholder' when the last tab in a tabber is closed

I'm building an app that will have a navigation tree on the left and tabbed editors in the center, much like your typical IDE (Eclipse or IntelliJ). When the user closes the last of the tabbed editors, I don't want the navigator to fill the entire screen, but rather put in a placeholder node.

I've done this at startup and remove it when the first editor is opened, but I'm having trouble restoring it when the last editor is removed. I've implemented close handlers and after the last one is removed, I toss a call onto the Platform.runLater() stack to re-add my placeholder, but it fails with an NPE when I try to dock my new placeholder node with the Station. It is like the station has changed and is no longer valid (it's the exact same code that initially created and installed the placeholder successfully).

Any ideas on a better way to approach this problem before I start digging in deeper?

TIA!
Chris

DockStation.restore(DockNode node) NullPointerException

In trying a single DockNode on a DockStation, I pressed maximize button twice, on the second press, it invoked restore(DockNode node). I got a NPE at line 190, panelParent is null.

Not sure the best approach to solve, as it was technically already maximized, so should the maximized be disabled? Or should the restore() have a != null check.

Either way, please keep up the good work, it is highly appreciated.

DockSplitterContainer dividerPositions

When attempting to build an Eclipse/Netbeans style multiple document interface, it would be beneficial to have access to DockSplitterContainer's set/get DividerPositions.

This would allow resizing of the DockStation (or SubStation) to prioritize the document Pane.

run AnchorFX_CommonStations exception

Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.anchorage.docks.containers.zones.DockZones.makePreview(DockZones.java:385)
at com.anchorage.docks.containers.zones.DockZones.searchArea(DockZones.java:257)
at com.anchorage.docks.stations.DockStation.searchTargetNode(DockStation.java:159)
at com.anchorage.system.AnchorageSystem.lambda$searchTargetNode$3(AnchorageSystem.java:104)
at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at com.anchorage.system.AnchorageSystem.searchTargetNode(AnchorageSystem.java:104)
at com.anchorage.docks.node.ui.DockUIPanel.manageDragEvent(DockUIPanel.java:153)
at com.anchorage.docks.node.ui.DockUIPanel.lambda$installDragEventMananger$1(DockUIPanel.java:122)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:380)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:294)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:416)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:415)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)
Exception in thread "JavaFX Application Thread" java.lang.NullPointerException
at com.anchorage.docks.node.DockNode.dock(DockNode.java:332)
at com.anchorage.docks.stations.DockStation.manageDockDestination(DockStation.java:222)
at com.anchorage.docks.stations.DockStation.finalizeDrag(DockStation.java:198)
at com.anchorage.system.AnchorageSystem.finalizeDragging(AnchorageSystem.java:124)
at com.anchorage.docks.node.ui.DockUIPanel.manageReleaseEvent(DockUIPanel.java:161)
at com.anchorage.docks.node.ui.DockUIPanel.lambda$installDragEventMananger$2(DockUIPanel.java:127)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:380)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:294)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:416)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:415)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:745)

Tab didn't invoke DockNodeCloseRequestHandler.canClose()

dockNode.setCloseRequestHandler(new DockNodeCloseRequestHandler() {
			@Override
			public boolean canClose() {
				return trueOrFalse();
			}
		});

I set this handler to every node that I docked.
But only the first and the second tab docked invoke canClose(),
I found out that this is because DockTabberContainer didn't put this

        newTab.setOnCloseRequest(event -> {
            if (node.getCloseRequestHandler() == null || node.getCloseRequestHandler().canClose()) {
            	node.undock();
                event.consume();
            }
        });

in putDock method like DockCommons did in createTabber method.

Pop-out transparent title-bar

On the pop-out windows, the text isn't intuitive as the drag location. In my first attempt at popping the window out the editor window landed on a black background which hid it fairly well.

image

JAR file for the complete framework

Can you please profide a compiled JAR file for the complete library. So that we can just test the demos and learn how to use the Lib. Thanks.

Gradle build file?

It seems like build.gradle disappeared when I pulled your updates to my fork. Was that intentional...or am I missing something?

nodes disappearing in CommonStations test/example

  1. start the AnchorFX_CommonStations test application
  2. drag a node (e.g. tree4) out of both windows (i.e. out by itself)
  3. drag that node back onto one of the two original windows (stations)
  4. the dragged node disappears

Is this the expected outcome, or a bug?

Everything seems to work fine, as long as the nodes are not dragged out of their stations.

Looks like a good project that will be very useful in my app. Nice job!

Also - is there any built-in support for saving the size/position/layout of nodes for restoring when the app is re-opened?

Problem with substation and floating

I have a problem with substation.
I first put a dock of the substation in floating mode. And when i want to put into the substation again, the dock disappears.

Thanks for your code.

README.md DockPosition fix

In the README file, there are a number of references to DockNode.DOCK_POSITION.<position>, but the recent bug fixes say it should be DockNode.DockPosition.<position>. This probably needs to be updated to reflect the changes.

Icon for nodes

provide the ability to add an icon to the node window

Move resources to an AnchorFX package

Currently all resources (png and css files) are located at the root of the source tree, placing them in the default package. This increases the chances of a collision when using AnchorFX with other projects.

Add unit tests

There are no real uni tests in this project. Docking system might be able to be tested without UI.

Minimize frame as button

Is it possible to create a button on the left or right if a frame is closed ? Like IntelliJ is doing ?
This is very handy to reopen a frame if minimized.

image

Moving DockNodes does not work under Linux

I discovered a strange behavior when I try to drag a DockNode. First, a window is created and dragged with the mouse movement (which I expect to be intended). But after around 100 ms this window get stuck. It does not follow the mouse anymore and it does not respond to any event. I cannot even close the extracted window anymore and it keeps staying on top of all windows when I switch to another application window.

My system is a 64 bit Linux system with a Kernel 3.13.0-100-generic running in a virtual machine (via VirtualBox).
Here's my java version:

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.