Initial commit from SVN.
This commit is contained in:
156
Foundation SWT/src/com/foundation/view/swt/StyleLineInfo.java
Normal file
156
Foundation SWT/src/com/foundation/view/swt/StyleLineInfo.java
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* Copyright (c) 2006 Declarative Engineering LLC.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Declarative Engineering LLC
|
||||
* verson 1 which accompanies this distribution, and is available at
|
||||
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||||
*/
|
||||
package com.foundation.view.swt;
|
||||
|
||||
import com.common.comparison.Comparator;
|
||||
import com.foundation.metadata.Attribute;
|
||||
import com.foundation.metadata.Event;
|
||||
import com.foundation.model.Model;
|
||||
|
||||
/*
|
||||
* An external structure for specifying line metadata for a section of text in the styled text control.
|
||||
* A null bullet reference indicates that there is no bulleting for the lines. If some lines have bulleting then the attribute will reference a bullet info instance.
|
||||
* <p>If the text represented by this info instance contains a mix of style settings then only the common styles will be set in this info object. The attributes for which there is a mix of data will be assigned a null value.</p>
|
||||
*/
|
||||
public class StyleLineInfo extends Model {
|
||||
/** The updated event is fired by the StyledTextManager after the styles have been updated due to a change in the selection. */
|
||||
public static final Event EVENT_UPDATED = registerEvent(StyleLineInfo.class, "eventUpdated");
|
||||
public static final Attribute ALIGNMENT = registerAttribute(StyleLineInfo.class, "alignment");
|
||||
public static final Attribute INDENT = registerAttribute(StyleLineInfo.class, "indent");
|
||||
public static final Attribute JUSTIFY = registerAttribute(StyleLineInfo.class, "justify");
|
||||
public static final Attribute STYLE = registerAttribute(StyleLineInfo.class, "style");
|
||||
public static final Attribute IS_BULLETED = registerAttribute(StyleLineInfo.class, "isBulleted");
|
||||
public static final Attribute BULLET = registerAttribute(StyleLineInfo.class, "bullet");
|
||||
/**
|
||||
* StyleLineInfo constructor.
|
||||
*/
|
||||
public StyleLineInfo() {
|
||||
super();
|
||||
setStyle(new StyleTextInfo());
|
||||
}//StyleLineInfo()//
|
||||
/**
|
||||
* Fires the updated event notifying listeners that the styled text manager has finished updating the style data due to a selection or cursor position change.
|
||||
* This event does not provide any information about what if anything has been changed. The change flags for the object are not currently utilized to provide this information either.
|
||||
*/
|
||||
protected void fireUpdated() {
|
||||
getEventSupport().fireEvent(EVENT_UPDATED);
|
||||
}//fireUpdated()//
|
||||
/**
|
||||
* Gets the alignment for the lines the style is associated with.
|
||||
* @return The alignment for all the text in the associated lines.
|
||||
*/
|
||||
public Integer getAlignment() {
|
||||
return (Integer) getAttributeValue(ALIGNMENT);
|
||||
}//getAlignment()//
|
||||
/**
|
||||
* Sets the alignment for the lines the style is associated with.
|
||||
* @param alignment The alignment for all the text in the associated lines.
|
||||
*/
|
||||
public void setAlignment(Integer alignment) {
|
||||
setAttributeValue(ALIGNMENT, alignment);
|
||||
}//setAlignment()//
|
||||
/**
|
||||
* Gets the indent for the lines the style is associated with.
|
||||
* @return The indent for all the text in the associated lines.
|
||||
*/
|
||||
public Integer getIndent() {
|
||||
return (Integer) getAttributeValue(INDENT);
|
||||
}//getIndent()//
|
||||
/**
|
||||
* Sets the indent for the lines the style is associated with.
|
||||
* @param indent The indent for all the text in the associated lines.
|
||||
*/
|
||||
public void setIndent(Integer indent) {
|
||||
setAttributeValue(INDENT, indent);
|
||||
}//setIndent()//
|
||||
/**
|
||||
* Gets whether the lines the style is associated with are justified.
|
||||
* @return Whether all the text in the associated lines are justified.
|
||||
*/
|
||||
public Boolean getJustify() {
|
||||
return (Boolean) getAttributeValue(JUSTIFY);
|
||||
}//getJustify()//
|
||||
/**
|
||||
* Sets whether the lines the style is associated with are justified.
|
||||
* @param justify Whether all the text in the associated lines are justified.
|
||||
*/
|
||||
public void setJustify(Boolean justify) {
|
||||
setAttributeValue(JUSTIFY, justify);
|
||||
}//setJustify()//
|
||||
/**
|
||||
* Gets the text style metadata for the represented text.
|
||||
* @return The style data for the represented text.
|
||||
*/
|
||||
public StyleTextInfo getStyle() {
|
||||
return (StyleTextInfo) getAttributeValue(STYLE);
|
||||
}//getStyle()//
|
||||
/**
|
||||
* Sets the text style metadata for the represented text.
|
||||
* @param style The style data for the represented text.
|
||||
*/
|
||||
private void setStyle(StyleTextInfo style) {
|
||||
setAttributeValue(STYLE, style);
|
||||
}//setStyle()//
|
||||
/**
|
||||
* Gets whether the lines are bulleted or not.
|
||||
* <p>This will be null if some lines are bulleted. If this is null then the bullet reference will be ignored when applying styles to the text.</p>
|
||||
* @return Whether all lines are bulleted or not.
|
||||
*/
|
||||
public Boolean getIsBulleted() {
|
||||
return (Boolean) getAttributeValue(IS_BULLETED);
|
||||
}//getIsBulleted()//
|
||||
/**
|
||||
* Sets whether the lines are bulleted or not.
|
||||
* <p>This will be null if some lines are bulleted. If this is null then the bullet reference will be ignored when applying styles to the text.</p>
|
||||
* @param isBulleted Whether all lines are bulleted or not.
|
||||
*/
|
||||
public void setIsBulleted(Boolean isBulleted) {
|
||||
setAttributeValue(IS_BULLETED, isBulleted);
|
||||
}//setIsBulleted()//
|
||||
/**
|
||||
* Gets the bullet metadata for the represented lines.
|
||||
* @return The bullet data which will be non-null if any of the represented lines have bullets.
|
||||
*/
|
||||
public StyleBulletInfo getBullet() {
|
||||
return (StyleBulletInfo) getAttributeValue(BULLET);
|
||||
}//getBullet()//
|
||||
/**
|
||||
* Sets the bullet metadata for the represented lines.
|
||||
* @param bullet The bullet data which will be non-null if any of the represented lines have bullets.
|
||||
*/
|
||||
public void setBullet(StyleBulletInfo bullet) {
|
||||
setAttributeValue(BULLET, bullet);
|
||||
}//setBullet()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return "Line Style";
|
||||
}//toString()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
public boolean equals(Object object) {
|
||||
return (object instanceof StyleLineInfo) &&
|
||||
Comparator.equals(getAlignment(), ((StyleLineInfo) object).getAlignment()) &&
|
||||
Comparator.equals(getIndent(), ((StyleLineInfo) object).getIndent()) &&
|
||||
Comparator.equals(getJustify(), ((StyleLineInfo) object).getJustify()) &&
|
||||
Comparator.equals(getBullet(), ((StyleLineInfo) object).getBullet()) &&
|
||||
Comparator.equals(getStyle(), ((StyleLineInfo) object).getStyle());
|
||||
}//equals()//
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public int hashCode() {
|
||||
return (getAlignment() == null ? 0 : getAlignment().hashCode()) ^
|
||||
(getIndent() == null ? 0 : getIndent().hashCode()) ^
|
||||
(getJustify() == null ? 0 : getJustify().hashCode()) ^
|
||||
(getBullet() == null ? 0 : getBullet().hashCode()) ^
|
||||
(getStyle() == null ? 0 : getStyle().hashCode());
|
||||
}//hashCode()//
|
||||
}//StyleLineInfo//
|
||||
Reference in New Issue
Block a user