📄 marker.java
字号:
*
* @see #setLabel(String)
*/
public String getLabel() {
return this.label;
}
/**
* Sets the label (if <code>null</code> no label is displayed) and sends a
* {@link MarkerChangeEvent} to all registered listeners.
*
* @param label the label (<code>null</code> permitted).
*
* @see #getLabel()
*/
public void setLabel(String label) {
this.label = label;
notifyListeners(new MarkerChangeEvent(this));
}
/**
* Returns the label font.
*
* @return The label font (never <code>null</code>).
*
* @see #setLabelFont(Font)
*/
public Font getLabelFont() {
return this.labelFont;
}
/**
* Sets the label font and sends a {@link MarkerChangeEvent} to all
* registered listeners.
*
* @param font the font (<code>null</code> not permitted).
*
* @see #getLabelFont()
*/
public void setLabelFont(Font font) {
if (font == null) {
throw new IllegalArgumentException("Null 'font' argument.");
}
this.labelFont = font;
notifyListeners(new MarkerChangeEvent(this));
}
/**
* Returns the label paint.
*
* @return The label paint (never </code>null</code>).
*
* @see #setLabelPaint(Paint)
*/
public Paint getLabelPaint() {
return this.labelPaint;
}
/**
* Sets the label paint and sends a {@link MarkerChangeEvent} to all
* registered listeners.
*
* @param paint the paint (<code>null</code> not permitted).
*
* @see #getLabelPaint()
*/
public void setLabelPaint(Paint paint) {
if (paint == null) {
throw new IllegalArgumentException("Null 'paint' argument.");
}
this.labelPaint = paint;
notifyListeners(new MarkerChangeEvent(this));
}
/**
* Returns the label anchor. This defines the position of the label
* anchor, relative to the bounds of the marker.
*
* @return The label anchor (never <code>null</code>).
*
* @see #setLabelAnchor(RectangleAnchor)
*/
public RectangleAnchor getLabelAnchor() {
return this.labelAnchor;
}
/**
* Sets the label anchor and sends a {@link MarkerChangeEvent} to all
* registered listeners. The anchor defines the position of the label
* anchor, relative to the bounds of the marker.
*
* @param anchor the anchor (<code>null</code> not permitted).
*
* @see #getLabelAnchor()
*/
public void setLabelAnchor(RectangleAnchor anchor) {
if (anchor == null) {
throw new IllegalArgumentException("Null 'anchor' argument.");
}
this.labelAnchor = anchor;
notifyListeners(new MarkerChangeEvent(this));
}
/**
* Returns the label offset.
*
* @return The label offset (never <code>null</code>).
*
* @see #setLabelOffset(RectangleInsets)
*/
public RectangleInsets getLabelOffset() {
return this.labelOffset;
}
/**
* Sets the label offset and sends a {@link MarkerChangeEvent} to all
* registered listeners.
*
* @param offset the label offset (<code>null</code> not permitted).
*
* @see #getLabelOffset()
*/
public void setLabelOffset(RectangleInsets offset) {
if (offset == null) {
throw new IllegalArgumentException("Null 'offset' argument.");
}
this.labelOffset = offset;
notifyListeners(new MarkerChangeEvent(this));
}
/**
* Returns the label offset type.
*
* @return The type (never <code>null</code>).
*
* @see #setLabelOffsetType(LengthAdjustmentType)
*/
public LengthAdjustmentType getLabelOffsetType() {
return this.labelOffsetType;
}
/**
* Sets the label offset type and sends a {@link MarkerChangeEvent} to all
* registered listeners.
*
* @param adj the type (<code>null</code> not permitted).
*
* @see #getLabelOffsetType()
*/
public void setLabelOffsetType(LengthAdjustmentType adj) {
if (adj == null) {
throw new IllegalArgumentException("Null 'adj' argument.");
}
this.labelOffsetType = adj;
notifyListeners(new MarkerChangeEvent(this));
}
/**
* Returns the label text anchor.
*
* @return The label text anchor (never <code>null</code>).
*
* @see #setLabelTextAnchor(TextAnchor)
*/
public TextAnchor getLabelTextAnchor() {
return this.labelTextAnchor;
}
/**
* Sets the label text anchor and sends a {@link MarkerChangeEvent} to
* all registered listeners.
*
* @param anchor the label text anchor (<code>null</code> not permitted).
*
* @see #getLabelTextAnchor()
*/
public void setLabelTextAnchor(TextAnchor anchor) {
if (anchor == null) {
throw new IllegalArgumentException("Null 'anchor' argument.");
}
this.labelTextAnchor = anchor;
notifyListeners(new MarkerChangeEvent(this));
}
/**
* Registers an object for notification of changes to the marker.
*
* @param listener the object to be registered.
*
* @since 1.0.3
*/
public void addChangeListener(MarkerChangeListener listener) {
this.listenerList.add(MarkerChangeListener.class, listener);
}
/**
* Unregisters an object for notification of changes to the marker.
*
* @param listener the object to be unregistered.
*
* @since 1.0.3
*/
public void removeChangeListener(MarkerChangeListener listener) {
this.listenerList.remove(MarkerChangeListener.class, listener);
}
/**
* Notifies all registered listeners that the marker has been modified.
*
* @param event information about the change event.
*
* @since 1.0.3
*/
public void notifyListeners(MarkerChangeEvent event) {
Object[] listeners = this.listenerList.getListenerList();
for (int i = listeners.length - 2; i >= 0; i -= 2) {
if (listeners[i] == MarkerChangeListener.class) {
((MarkerChangeListener) listeners[i + 1]).markerChanged(event);
}
}
}
/**
* Returns an array containing all the listeners of the specified type.
*
* @param listenerType the listener type.
*
* @return The array of listeners.
*
* @since 1.0.3
*/
public EventListener[] getListeners(Class listenerType) {
return this.listenerList.getListeners(listenerType);
}
/**
* Tests the marker for equality with an arbitrary object.
*
* @param obj the object (<code>null</code> permitted).
*
* @return A boolean.
*/
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Marker)) {
return false;
}
Marker that = (Marker) obj;
if (!PaintUtilities.equal(this.paint, that.paint)) {
return false;
}
if (!ObjectUtilities.equal(this.stroke, that.stroke)) {
return false;
}
if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) {
return false;
}
if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) {
return false;
}
if (this.alpha != that.alpha) {
return false;
}
if (!ObjectUtilities.equal(this.label, that.label)) {
return false;
}
if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) {
return false;
}
if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) {
return false;
}
if (this.labelAnchor != that.labelAnchor) {
return false;
}
if (this.labelTextAnchor != that.labelTextAnchor) {
return false;
}
if (!ObjectUtilities.equal(this.labelOffset, that.labelOffset)) {
return false;
}
if (!this.labelOffsetType.equals(that.labelOffsetType)) {
return false;
}
return true;
}
/**
* Creates a clone of the marker.
*
* @return A clone.
*
* @throws CloneNotSupportedException never.
*/
public Object clone() throws CloneNotSupportedException {
return super.clone();
}
/**
* Provides serialization support.
*
* @param stream the output stream.
*
* @throws IOException if there is an I/O error.
*/
private void writeObject(ObjectOutputStream stream) throws IOException {
stream.defaultWriteObject();
SerialUtilities.writePaint(this.paint, stream);
SerialUtilities.writeStroke(this.stroke, stream);
SerialUtilities.writePaint(this.outlinePaint, stream);
SerialUtilities.writeStroke(this.outlineStroke, stream);
SerialUtilities.writePaint(this.labelPaint, stream);
}
/**
* Provides serialization support.
*
* @param stream the input stream.
*
* @throws IOException if there is an I/O error.
* @throws ClassNotFoundException if there is a classpath problem.
*/
private void readObject(ObjectInputStream stream)
throws IOException, ClassNotFoundException {
stream.defaultReadObject();
this.paint = SerialUtilities.readPaint(stream);
this.stroke = SerialUtilities.readStroke(stream);
this.outlinePaint = SerialUtilities.readPaint(stream);
this.outlineStroke = SerialUtilities.readStroke(stream);
this.labelPaint = SerialUtilities.readPaint(stream);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -