Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* CornerMenu.java
*
* Copyright (c) 2011-2016, JFXtras
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the organization nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package jfxtras.scene.menu;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicLong;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.ReadOnlyBooleanProperty;
import javafx.beans.property.ReadOnlyBooleanWrapper;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.control.MenuItem;
import javafx.scene.control.Tooltip;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.Pane;
import javafx.util.Duration;
import jfxtras.scene.layout.CircularPane;
import jfxtras.scene.layout.CircularPane.AnimationInterpolation;
/**
* CornerMenu is a menu is intended to be placed in one of the four corners of a pane.
* It will show the provided menu items in a 90 degree arc with the origin in the corner.
* It is possible to, and per default will, animate the menu items in and out of view.
* The showing and hiding of the menu items can be done automatically based on the mouse pointer location.
*
* CornerMenu requires a Pane to attach itself to.
*
* CornerMenu uses CircularPane and this will leak through in the API.
* For example: it is possible to customize the animation, and required interface to implement is the one from CircularPane.
*
* @author Tom Eugelink
*
*/
public class CornerMenu {
// ==================================================================================================================
// CONSTRUCTOR
/**
*/
public CornerMenu(Location location, Pane pane, boolean shown)
{
locationObjectProperty.set(location);
construct(pane, shown);
}
/*
*
*/
private void construct(Pane pane, boolean shown)
{
this.pane = pane;
// listen to items and modify circular pane's children accordingly
getItems().addListener( (ListChangeListener.Change extends MenuItem> change) -> {
while (change.next())
{
for (MenuItem lMenuItem : change.getRemoved())
{
for (javafx.scene.Node lNode : new ArrayList(circularPane.getChildren())) {
if (lNode instanceof CornerMenuNode) {
CornerMenuNode lCornerMenuNode = (CornerMenuNode)lNode;
if (lCornerMenuNode.menuItem == lMenuItem) {
circularPane.remove(lCornerMenuNode);
}
}
}
}
for (MenuItem lMenuItem : change.getAddedSubList())
{
circularPane.add( new CornerMenuNode(lMenuItem) );
}
}
circularPane.resize(circularPane.prefWidth(-1), circularPane.prefHeight(-1));
});
// auto show and hide
pane.addEventHandler(MouseEvent.MOUSE_MOVED, (mouseEvent) -> {
if (isAutoShowAndHide()) {
autoShowOrHide(mouseEvent);
}
});
// circular pane
setupCircularPane();
// add to pane
pane.getChildren().add(circularPane);
circularPane.setManaged(false);
// default status
circularPane.setVisible(shown);
setShown(shown);
}
private Pane pane = null;
// ==================================================================================================================
// PROPERTIES
/** Location: TOP_LEFT, TOP_RIGHT, BOTTOM_RIGHT, BOTTOM_LEFT */
public ReadOnlyObjectProperty locationProperty() {
return new ReadOnlyObjectWrapper(this, "location").getReadOnlyProperty();
}
final private SimpleObjectProperty locationObjectProperty = new SimpleObjectProperty(this, "location", Location.TOP_LEFT);
public static enum Location {TOP_LEFT, TOP_RIGHT, BOTTOM_RIGHT, BOTTOM_LEFT}
public Location getLocation() { return locationObjectProperty.getValue(); }
/** items */
private final ObservableList