|
|
|
package com.fr.plugin.cell.highlight.fun;
|
|
|
|
|
|
|
|
import com.fr.base.Style;
|
|
|
|
import com.fr.intelli.record.Focus;
|
|
|
|
import com.fr.intelli.record.Original;
|
|
|
|
import com.fr.plugin.PluginLicense;
|
|
|
|
import com.fr.plugin.PluginLicenseManager;
|
|
|
|
import com.fr.record.analyzer.EnableMetrics;
|
|
|
|
import com.fr.report.cell.CellElement;
|
|
|
|
import com.fr.report.cell.cellattr.highlight.AbstractStyleHighlightAction;
|
|
|
|
import com.fr.script.Calculator;
|
|
|
|
import com.fr.stable.AssistUtils;
|
|
|
|
import com.fr.stable.Constants;
|
|
|
|
import com.fr.stable.xml.XMLPrintWriter;
|
|
|
|
import com.fr.stable.xml.XMLableReader;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author richie
|
|
|
|
* @date 2015-03-26
|
|
|
|
* @since 8.0
|
|
|
|
*/
|
|
|
|
@EnableMetrics
|
|
|
|
public class AlignHighlightAction extends AbstractStyleHighlightAction {
|
|
|
|
|
|
|
|
private int align = Constants.RIGHT;
|
|
|
|
|
|
|
|
public AlignHighlightAction() {
|
|
|
|
this(Constants.RIGHT, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AlignHighlightAction(int align, int scope) {
|
|
|
|
super(scope);
|
|
|
|
this.align = align;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getAlign() {
|
|
|
|
return align;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void action(CellElement cellElement, Calculator calculator) {
|
|
|
|
super.action(cellElement, calculator);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Focus(id = AlignHighlightConstants.PLUGIN_ID, text = "Plugin-Highlight_Align", source = Original.PLUGIN)
|
|
|
|
protected Style modStyle(Style style) {
|
|
|
|
PluginLicense pluginLicense = PluginLicenseManager.getInstance().getPluginLicenseByID(AlignHighlightConstants.PLUGIN_ID);
|
|
|
|
if (pluginLicense != null && pluginLicense.isAvailable()) {
|
|
|
|
return style.deriveHorizontalAlignment(align);
|
|
|
|
}
|
|
|
|
return style;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void readXML(XMLableReader reader) {
|
|
|
|
if (reader.isChildNode()) {
|
|
|
|
String tagName = reader.getTagName();
|
|
|
|
if (tagName.equals("Align")) {
|
|
|
|
align = reader.getAttrAsInt("align", Constants.RIGHT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void writeXML(XMLPrintWriter writer) {
|
|
|
|
writer.startTAG("Align").attr("align", align);
|
|
|
|
writer.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
return o instanceof AlignHighlightAction && super.equals(o) && ((AlignHighlightAction) o).align == align;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return AssistUtils.hashCode(align);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Object clone() throws CloneNotSupportedException {
|
|
|
|
AlignHighlightAction cloned = (AlignHighlightAction) super.clone();
|
|
|
|
cloned.align = align;
|
|
|
|
return cloned;
|
|
|
|
}
|
|
|
|
}
|