|
|
|
/*
|
|
|
|
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved.
|
|
|
|
*/
|
|
|
|
package com.fr.grid;
|
|
|
|
|
|
|
|
import java.awt.Dimension;
|
|
|
|
|
|
|
|
import com.fr.base.GraphHelper;
|
|
|
|
import com.fr.design.mainframe.DesignerUIModeConfig;
|
|
|
|
import com.fr.design.mainframe.ElementCasePane;
|
|
|
|
import com.fr.stable.StableUtils;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* GridColumn used to paint and edit grid column.
|
|
|
|
*
|
|
|
|
* @editor zhou
|
|
|
|
* @since 2012-3-22下午6:12:40
|
|
|
|
*/
|
|
|
|
public class GridColumn extends GridHeader<String> {
|
|
|
|
|
|
|
|
|
|
|
|
private GridColumnMouseHandler gridColumnMouseHandler;
|
|
|
|
private int adsorbWidth;
|
|
|
|
|
|
|
|
public GridColumn(int resolution) {
|
|
|
|
this(resolution, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public GridColumn(int resolution, int adsorbWidth) {
|
|
|
|
super(resolution);
|
|
|
|
this.adsorbWidth = adsorbWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void initByConstructor() {
|
|
|
|
this.updateUI();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getDisplay(int index) {
|
|
|
|
return StableUtils.convertIntToABC(index + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void updateUI() {
|
|
|
|
this.removeMouseListener(gridColumnMouseHandler);
|
|
|
|
this.removeMouseMotionListener(gridColumnMouseHandler);
|
|
|
|
gridColumnMouseHandler = new GridColumnMouseHandler(this, adsorbWidth);
|
|
|
|
this.addMouseListener(gridColumnMouseHandler);
|
|
|
|
this.addMouseMotionListener(gridColumnMouseHandler);
|
|
|
|
this.setUI(new GridColumnUI(resolution));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the preferred size.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Dimension getPreferredSize() {
|
|
|
|
ElementCasePane reportPane = this.getElementCasePane();
|
|
|
|
float time = (float) reportPane.getResolution() / DesignerUIModeConfig.getInstance().getScreenResolution();
|
|
|
|
if (!reportPane.isColumnHeaderVisible()) {
|
|
|
|
return new Dimension(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Dimension(super.getPreferredSize().width, (int) (GraphHelper.getFontMetrics(this.getFont()).getHeight() * time + SIZE_ADJUST));
|
|
|
|
}
|
|
|
|
}
|