/** * returns the weights how much a individual column contributes to the overall scores, i.e. the * normalized weights * * @return */ public float[] getWeights() { float[] r = new float[this.size()]; float base = width - getSpaces(); int i = 0; for (ARankColumnModel col : this) { r[i++] = (float) col.getParentData() / base; } return r; }
public void setWeights(float[] weights) { assert this.size() == weights.length; float sum = 0; for (float v : weights) sum += v; float factor = (width - getSpaces()) / sum; int i = 0; for (ARankColumnModel col : this) { float w = weights[i++] * factor; col.setParentData(w); col.setWidthImpl(w); } propertySupport.firePropertyChange(PROP_WEIGHTS, null, weights); }
@Override protected void takeDown(ARankColumnModel model) { super.takeDown(model); model.removePropertyChangeListener(PROP_WIDTH, listener); model.removePropertyChangeListener(IFilterColumnMixin.PROP_FILTER, listener); model.removePropertyChangeListener(IMappedColumnMixin.PROP_MAPPING, listener); // addDirectWeight(-model.getWeight()); if (alignmentDetails > size() - 2) { setAlignment(alignmentDetails - 1); } super.setWidth(width - model.getWidth() - RenderStyle.COLUMN_SPACE); model.setParentData(null); cacheMulti.clear(); }
@Override protected void init(IRankColumnParent table) { super.init(table); RankTableModel t = getTable(); t.addPropertyChangeListener(RankTableModel.PROP_DATA, listener); maskInvalid.set(0, t.getDataSize()); }
@Override protected void init(ARankColumnModel model) { super.init(model); model.addPropertyChangeListener(PROP_WIDTH, listener); model.addPropertyChangeListener(IFilterColumnMixin.PROP_FILTER, listener); model.addPropertyChangeListener(IMappedColumnMixin.PROP_MAPPING, listener); // addDirectWeight(model.getWeight()); cacheMulti.clear(); float oldWidth = size() == 1 ? (getSpaces() - RenderStyle.COLUMN_SPACE) : width; super.setWidth(oldWidth + model.getWidth() + RenderStyle.COLUMN_SPACE); model.setParentData(model.getWidth()); }
@Override public ARankColumnModel setWidth(float width) { if (isCompressed) { this.propertySupport.firePropertyChange( PROP_WIDTH, compressedWidth, this.compressedWidth = width); return this; } float shift = getSpaces(); float factor = (width - shift) / (this.width - shift); // new / old for (ARankColumnModel col : this) { float wi = ((float) col.getParentData()) * factor; col.setParentData(wi); col.removePropertyChangeListener(PROP_WIDTH, listener); col.setWidth(wi); col.addPropertyChangeListener(PROP_WIDTH, listener); } return super.setWidth(width); }
@Override protected void takeDown() { getTable().removePropertyChangeListener(RankTableModel.PROP_DATA, listener); super.takeDown(); }
protected void onWeightChanged(ARankColumnModel child, float oldValue, float newValue) { child.setParentData(newValue); super.setWidth(width + (newValue - oldValue)); }