📄 layermanagerlayer.java
字号:
* Get the layer manager frame offset from the viewport borders.
*
* @return the number of pixels to offset the layer manager frame from the borders indicated
* by {@link #setPosition(String)}.
*/
public int getBorderWidth()
{
return borderWidth;
}
/**
* Sets the layer manager frame offset from the viewport borders.
*
* @param borderWidth the number of pixels to offset the layer manager frame from the borders indicated
* by {@link #setPosition(String)}.
*/
public void setBorderWidth(int borderWidth)
{
this.borderWidth = borderWidth;
this.update();
}
/**
* Returns the current relative layer manager frame position.
*
* @return the current layer manager frame position
*/
public String getPosition()
{
return position;
}
/**
* Sets the relative viewport location to display the layer manager. Can be one of {@link AVKey#NORTHEAST}
* (the default), {@link AVKey#NORTHWEST}, {@link AVKey#SOUTHEAST}, or {@link AVKey#SOUTHWEST}. These
* indicate the corner of the viewport to place the frame.
*
* @param position the desired layer manager position
*/
public void setPosition(String position)
{
if (position == null)
{
String message = Logging.getMessage("nullValue.ScreenPositionIsNull");
Logging.logger().severe(message);
throw new IllegalArgumentException(message);
}
this.position = position;
this.update();
}
/**
* Returns the current layer manager location.
*
* @return the current location center. May be null.
*/
public Vec4 getLocationCenter()
{
return locationCenter;
}
/**
* Specifies the screen location of the layer manager, relative to it's frame center. May be null. If this value is
* non-null, it overrides the position specified by #setPosition. The location is specified in pixels. The origin is
* the window's lower left corner. Positive X values are to the right of the origin, positive Y values are upwards
* from the origin. The final frame location will be affected by the currently specified location offset if a
* non-null location offset has been specified (see {@link #setLocationOffset(Vec4)}).
*
* @param locationCenter the location center. May be null.
* @see #setPosition, #setLocationOffset
*/
public void setLocationCenter(Vec4 locationCenter)
{
this.locationCenter = locationCenter;
this.update();
}
/**
* Returns the current location offset. See #setLocationOffset for a description of the offset and its values.
*
* @return the location offset. Will be null if no offset has been specified.
*/
public Vec4 getLocationOffset()
{
return locationOffset;
}
/**
* Specifies a placement offset from the layer manager frame position on the screen.
*
* @param locationOffset the number of pixels to shift the layer manager frame from its specified screen
* position. A positive X value shifts the frame to the right. A positive Y value shifts the frame up.
* If null, no offset is applied. The default offset is null.
* @see #setLocationCenter, #setPosition
*/
public void setLocationOffset(Vec4 locationOffset)
{
this.locationOffset = locationOffset;
this.update();
}
/**
* Determines whether the layer list frame is minimized. When minimized, the layer list only contains
* itself as the only item, and thus shrinks toward it's corner position.
*
* @return <ode>true</code> if the layer list frame is minimized.
*/
public boolean isMinimized()
{
return this.minimized;
}
/**
* Set the layer list frame to be minimized. When minimized, the layer list only contains
* itself as the only item, and thus shrinks toward it's corner position.
*
* @param minimized <ode>true</code> if the layer list frame sould be minimized.
*/
public void setMinimized(boolean minimized)
{
this.minimized = minimized;
this.update();
}
/**
* Determines whether the layer list can be moved or dragged with the mouse cursor.
* <p>
* If enabled, dragging the frame will result in a change to it's location offset -
* {@link #setLocationOffset(Vec4)}. If the list is also set to snap to corners -
* {@link #setSnapToCorners(boolean)}, the frame position may change so as to be attached
* to the nearest corner - see {@link #setPosition(String)}.
*
* @return <code>true</code> if the layer list can be moved or dragged with the mouse cursor.
*/
public boolean isComponentDragEnabled()
{
return this.componentDragEnabled;
}
/**
* Sets whether the layer list can be moved or dragged with the mouse cursor.
* <p>
* If enabled, dragging the frame will result in a change to it's location offset -
* {@link #setLocationOffset(Vec4)}. If the list is also set to snap to corners -
* {@link #setSnapToCorners(boolean)}, the frame position may change so as to be attached
* to the nearest corner - see {@link #setPosition(String)}.
*
* @param enabled <code>true</code> if the layer list can be moved or dragged with the mouse cursor.
*/
public void setComponentDragEnabled(boolean enabled)
{
this.componentDragEnabled = enabled;
}
/**
* Determines whether a layer can be moved or dragged within the list with the mouse cursor. If enabled,
* layers can be moved up and down the list.
*
* @return <code>true</code> if a layer can be moved or dragged within the list.
*/
public boolean isLayerDragEnabled()
{
return this.layerDragEnabled;
}
/**
* Sets whether a layer can be moved or dragged within the list with the mouse cursor. If enabled,
* layers can be moved up and down the list.
*
* @param enabled <code>true</code> if a layer can be moved or dragged within the list.
*/
public void setLayerDragEnabled(boolean enabled)
{
this.layerDragEnabled = enabled;
}
/**
* Determines whether the layer list snaps to the viewport sides and corners while being dragged.
* <p>
* Dragging the layer list frame will result in a change to it's location offset -
* {@link #setLocationOffset(Vec4)}. If the list is also set to snap to corners -
* {@link #setSnapToCorners(boolean)}, the frame position may change so as to be attached
* to the nearest corner - see {@link #setPosition(String)}.
*
* @return <code>true</code> if the layer list snaps to the viewport sides and corners while being dragged.
*/
public boolean isSnapToCorners()
{
return this.snapToCorners;
}
/**
* Sets whether the layer list snaps to the viewport sides and corners while being dragged.
* <p>
* Dragging the layer list frame will result in a change to it's location offset -
* {@link #setLocationOffset(Vec4)}. If the list is also set to snap to corners the frame position may
* change so as to be attached to the nearest corner - see {@link #setPosition(String)}.
*
* @param enabled <code>true</code> if the layer list should snaps to the viewport sides and corners
* while being dragged.
*/
public void setSnapToCorners(boolean enabled)
{
this.snapToCorners = enabled;
}
/**
* Get the selected layer index number in the current <code>Model</code> layer list. A layer is selected
* when the cursor is over it in the list. Returns -1 if no layer is currently selected.
*
* @return the selected layer index number or -1 if none is selected.
*/
public int getSelectedIndex()
{
return this.selectedIndex;
}
/**
* Set the selected layer index number. When selected a layer is highlighted in the list - this usually
* happens when the cursor is over it.
*
* @param index the selected layer index number.
*/
public void setSelectedIndex(int index)
{
this.selectedIndex = index;
this.update();
}
/**
* <code>SelectListener</code> implementation.
*
* @param event the current <code>SelectEvent</code>
*/
public void selected(SelectEvent event)
{
if (event.hasObjects() && event.getTopObject() == this.annotation)
{
boolean update = false;
if (event.getEventAction().equals(SelectEvent.ROLLOVER)
|| event.getEventAction().equals(SelectEvent.LEFT_CLICK))
{
// Highlight annotation
if (!this.annotation.getAttributes().isHighlighted())
{
this.annotation.getAttributes().setHighlighted(true);
update = true;
}
// Check for text or url
PickedObject po = event.getTopPickedObject();
if(po.getValue(AVKey.URL) != null)
{
// Set cursor hand on hyperlinks
((Component)this.wwd).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
int i = Integer.parseInt((String)po.getValue(AVKey.URL));
// Select current hyperlink
if (this.selectedIndex != i)
{
this.selectedIndex = i;
update = true;
}
// Enable/disable layer on left click
if (event.getEventAction().equals(SelectEvent.LEFT_CLICK))
{
LayerList layers = wwd.getModel().getLayers();
if (i >= 0 && i < layers.size())
{
layers.get(i).setEnabled(!layers.get(i).isEnabled());
update = true;
}
}
}
else
{
// Unselect if not on an hyperlink
if (this.selectedIndex != -1)
{
this.selectedIndex = -1;
update = true;
}
// Set cursor
if (this.isComponentDragEnabled())
((Component)this.wwd).setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
else
((Component)this.wwd).setCursor(Cursor.getDefaultCursor());
}
}
if (event.getEventAction().equals(SelectEvent.DRAG)
|| event.getEventAction().equals(SelectEvent.DRAG_END))
{
// Handle dragging
if (this.isComponentDragEnabled() || this.isLayerDragEnabled())
{
boolean wasDraggingLayer = this.draggingLayer;
this.drag(event);
// Update list if dragging a layer, otherwise just redraw the world window
if(this.draggingLayer || wasDraggingLayer)
update = true;
else
this.wwd.redraw();
}
}
// Redraw annotation if needed
if (update)
this.update();
}
else if (event.getEventAction().equals(SelectEvent.ROLLOVER) && this.annotation.getAttributes().isHighlighted())
{
// de-highlight annotation
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -