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.
/***********************************************************************************************************************
*
* OpenBlueSky - NetBeans Platform Enhancements
* Copyright (C) 2006-2012 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
***********************************************************************************************************************
*
* WWW: http://openbluesky.java.net
* SCM: https://bitbucket.org/tidalwave/openbluesky-src
*
**********************************************************************************************************************/
package it.tidalwave.netbeans.visual;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.annotation.Nonnull;
import java.lang.reflect.Method;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelListener;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.OverlayLayout;
import java.io.Serializable;
import org.openide.util.WeakListeners;
import org.netbeans.api.visual.widget.Widget;
import org.netbeans.api.visual.widget.Scene.SceneListener;
import org.netbeans.api.visual.model.ObjectScene;
import it.tidalwave.util.logging.Logger;
import it.tidalwave.netbeans.visual.impl.MouseEventForwarder;
import it.tidalwave.netbeans.visual.impl.RevalidateTrigger;
import it.tidalwave.netbeans.visual.impl.SceneDropTarget;
import java.awt.datatransfer.DataFlavor;
/***********************************************************************************************************************
*
* This class allows to create a layered view of an {@link ObjectScene}, in which contents can be rendered below
* (background) and in front (foreground) of the {@code Widget}s, that are achored to meaningful positions in function
* of the background. This means that {@code Widget}s can be made "stick" to background contents even when the latter
* change or move. A typical use is with a map in the foreground and {@code Widget}s represent features sticking on it.
*
* The position of each {@code Widget} is computed by a scene-wise {@link LocationProvider} that is called whenever
* the {@code Scene} is revalidated. The {@code Scene} must be revalidated each time the background or foreground
* contents are changed or moved. If the component responsible for rendering the background or the foreground fires
* event in such a case, the {@link #addRevalidateTrigger(java.lang.Object, java.lang.String[])} method can be
* conveniently used on that purpose.
*
* @author Fabrizio Giudici
* @version $Id$
*
**********************************************************************************************************************/
public class LayeredSceneView extends JLayeredPane
{
private static final String CLASS = LayeredSceneView.class.getName();
private static final Logger logger = Logger.getLogger(CLASS);
/*******************************************************************************************************************
*
* An instance of this class must be provided to each {@link LayeredSceneView} to compute the positions of
* {@link Widget}s.
*
******************************************************************************************************************/
public static interface LocationProvider extends Serializable
{
/***************************************************************************************************************
*
* This method computes the position where the {@link Widget} associated to the given {@code Object} should be
* placed. This method is called whenever the {@code Scene} is validated. The {@code Object} is the same
* instance that has been associated to the {@link Widget} by the {@code ObjectScene}.
*
* It is possible to return {@code null} to mean that the relevant {@code Widget} position must not be updated.
* This can happen, for instance, in mixed contexts where only part of the {@code Widget}s must get stuck on the
* background or when some of the {@code Widget}s are anchored to others.
*
* @param object the object
* @return the position
*
**************************************************************************************************************/
@Nullable
public Point findLocation (@Nonnull T object);
}
private final static Dimension ZERO = new Dimension(0, 0);
private static final LocationProvider