javax.swing.JPanel#removeAll ( )源码实例Demo

下面列出了javax.swing.JPanel#removeAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CQL   文件: AqlViewer.java
private <X, Y> void viewAlgebraHelper(JComponent top, Algebra<Ty, En, Sym, Fk, Att, Gen, Sk, X, Y> algebra,
		JPanel out, JCheckBox simp, JSlider sl, Map<Pair<Boolean, Integer>, JScrollPane> cache) {
	boolean b = simp.isSelected();
	int l = sl.getValue();
	Pair<Boolean, Integer> p = new Pair<>(b, l);
	JScrollPane jsp = cache.get(p);
	if (jsp == null) {
		jsp = makeList2(algebra, b, l);
		cache.put(p, jsp);
	}
	out.removeAll();
	out.add(jsp, BorderLayout.CENTER);
	out.add(top, BorderLayout.SOUTH);
	out.revalidate();
	out.repaint();
}
 
源代码2 项目: freecol   文件: EndTurnDialog.java
/**
 * {@inheritDoc}
 */
@Override
public Component getListCellRendererComponent(JList<? extends UnitWrapper> list,
                                              UnitWrapper value,
                                              int index,
                                              boolean isSelected,
                                              boolean cellHasFocus) {
    imageLabel.setIcon(new ImageIcon(
        getImageLibrary().getSmallerUnitImage(value.unit)));
    nameLabel.setText(value.name);
    locationLabel.setText(value.location);

    JPanel panel = (isSelected) ? selectedPanel : itemPanel;
    panel.removeAll();
    panel.add(imageLabel, "center, width 40!, height 40!");
    panel.add(nameLabel, "split 2, flowy");
    panel.add(locationLabel);
    return panel;
}
 
源代码3 项目: NBANDROID-V2   文件: AndroidSdkNode.java
public void updateCustomizer() {
    if (valid != platform.isValid()) {
        valid = platform.isValid();
        setChildren(Children.create(new AndroidPlatformChildrenFactory(platform, holder), false));
        JPanel tmp = lastBrokenPanel.get();
        if (tmp != null) {
            tmp.removeAll();
            tmp.invalidate();
            tmp.repaint();
            tmp.setLayout(new java.awt.CardLayout());
            if (platform.isValid()) {
                tmp.add(new AndroidSdkCustomizer(platform, holder));
            } else {
                tmp.add(new BrokenPlatformCustomizer(platform, holder, this));
            }
            tmp.revalidate();
            tmp.repaint();
            tmp.requestFocus();
        }
    }
}
 
源代码4 项目: moa   文件: StreamPanel.java
private void drawClustering(JPanel layer, Clustering clustering, List<DataPoint> points, Color color){
    if (clustering.get(0) instanceof NonConvexCluster) {
    	drawNonConvexClustering(layer, clustering, points, color);
    } else {	
 	layer.removeAll();
     for (int c = 0; c < clustering.size(); c++) {
         SphereCluster cluster = (SphereCluster)clustering.get(c);
	
         ClusterPanel clusterpanel = new ClusterPanel(cluster, color, this);
         
         layer.add(clusterpanel);
         clusterpanel.updateLocation();
     }
	
     if(layer.isVisible() && pointsVisible){
         Graphics2D imageGraphics = (Graphics2D) pointCanvas.createGraphics();
         imageGraphics.setColor(color);
         drawClusteringsOnCanvas(layer, imageGraphics);
         layerPointCanvas.repaint();
     }
	
     layer.repaint();
    }
}
 
源代码5 项目: pumpernickel   文件: QOptionPaneUI.java
protected void updateFooter(QOptionPane optionPane) {
	JPanel footerContainer = getFooterContainer(optionPane);
	DialogFooter dialogFooter = optionPane.getDialogFooter();
	footerContainer.removeAll();
	if (dialogFooter == null) {
		footerContainer.setVisible(false);
	} else {
		GridBagConstraints gbc = new GridBagConstraints();
		gbc.gridx = 0;
		gbc.gridy = 0;
		gbc.weightx = 1;
		gbc.weighty = 1;
		gbc.fill = GridBagConstraints.BOTH;
		footerContainer.setLayout(new GridBagLayout());
		footerContainer.add(dialogFooter, gbc);
		footerContainer.setVisible(true);
		dialogFooter.setOpaque(false);
	}
}
 
源代码6 项目: moa   文件: StreamOutlierPanel.java
private void drawOutliers(JPanel layer, Vector<Outlier> outliers, Color color){        
    layer.removeAll();
    for (Outlier outlier : outliers) {  
        int length = outlier.inst.numValues() - 1; // -1
        double[] center = new double[length]; // last value is the class
        for (int i = 0; i < length; i++) {
            center[i] = outlier.inst.value(i);                
        }            
        SphereCluster cluster = new SphereCluster(center, 0);                
            
        OutlierPanel outlierpanel = new OutlierPanel(m_outlierDetector, outlier, cluster, color, this);
        
        layer.add(outlierpanel);
        outlierpanel.updateLocation();
    }

    layer.repaint();
}
 
源代码7 项目: mzmine3   文件: ChartLogics.java
/**
 * 
 * Domain and Range axes need to share the same unit (e.g. mm)
 * 
 * @param myChart
 * @return
 */
public static double calcWidthToHeight(ChartPanel myChart, double chartHeight) {
  makeChartResizable(myChart);
  // paint on a ghost panel
  JPanel parent = (JPanel) myChart.getParent();
  JPanel p = new JPanel();
  p.removeAll();
  p.add(myChart, BorderLayout.CENTER);
  p.setBounds(myChart.getBounds());
  myChart.paintImmediately(myChart.getBounds());
  p.removeAll();
  parent.add(myChart);

  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  ChartRenderingInfo info = myChart.getChartRenderingInfo();
  Rectangle2D dataArea = info.getPlotInfo().getDataArea();
  Rectangle2D chartArea = info.getChartArea();

  // calc title space: will be added later to the right plot size
  double titleWidth = chartArea.getWidth() - dataArea.getWidth();
  double titleHeight = chartArea.getHeight() - dataArea.getHeight();

  // calc right plot size with axis dim.
  // real plot width is given by factor;
  double realPH = chartHeight - titleHeight;

  // ranges
  ValueAxis domainAxis = plot.getDomainAxis();
  org.jfree.data.Range x = domainAxis.getRange();
  ValueAxis rangeAxis = plot.getRangeAxis();
  org.jfree.data.Range y = rangeAxis.getRange();

  // real plot height can be calculated by
  double realPW = realPH / y.getLength() * x.getLength();

  double width = realPW + titleWidth;

  return width;
}
 
源代码8 项目: netbeans   文件: MenuEditLayer.java
private void rebuildOnScreenMenu(RADVisualContainer menuRAD) {
    if(menuRAD == null) return;
    if(hackedPopupFactory == null) return;
    JMenu menu = (JMenu) formDesigner.getComponent(menuRAD);
    if(hackedPopupFactory.containerMap.containsKey(menu)) {
        JPanel popupContainer = hackedPopupFactory.containerMap.get(menu);
        if(popupContainer == null) return;
        for(Component c : popupContainer.getComponents()) {
            if(c instanceof JMenu) {
                unconfigureMenu((JMenu)c);
            } else {
                unconfigureMenuItem((JComponent)c);
            }
        }
        popupContainer.removeAll();
        // rebuild it
        for(RADVisualComponent child : menuRAD.getSubComponents()) {
            if(child != null) {
                JComponent jchild = (JComponent) formDesigner.getComponent(child);
                if(!isConfigured(jchild)) {
                    if(jchild instanceof JMenu) {
                        configureMenu(menu, (JMenu)jchild);
                    } else {
                        configureMenuItem(menu,jchild);
                    }
                }
                popupContainer.add(jchild);
            }
        }
        
        // repack it
        popupContainer.setSize(popupContainer.getLayout().preferredLayoutSize(popupContainer));
        validate();
        popupContainer.repaint();
    }
}
 
源代码9 项目: netbeans   文件: MultiTabsPanel.java
@Override
protected void initTabsPanel( JPanel panel ) {
    if( null == tabsPanel )
        tabsPanel = new InnerTabsPanel( ( MultiTabsOptionsPanelController ) controller);
    panel.removeAll();
    panel.setLayout( new BorderLayout() );
    panel.add( tabsPanel, BorderLayout.CENTER );
}
 
源代码10 项目: netbeans   文件: CollapsibleSectionPanel.java
public ActionsBuilder (JPanel panel, FocusListener listener) {
    this.focusListener = listener;
    panel.removeAll();
    GroupLayout layout = (GroupLayout) panel.getLayout();
    horizontalSeqGroup = layout.createSequentialGroup();
    layout.setHorizontalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(horizontalSeqGroup)
    );
    verticalParallelGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(verticalParallelGroup)
    );
}
 
源代码11 项目: netbeans   文件: SectionPanel.java
public ActionsBuilder (JPanel panel) {
    panel.removeAll();
    GroupLayout layout = (GroupLayout) panel.getLayout();
    horizontalSeqGroup = layout.createSequentialGroup();
    layout.setHorizontalGroup(
        layout.createParallelGroup(GroupLayout.Alignment.LEADING)
        .addGroup(horizontalSeqGroup)
    );
    verticalParallelGroup = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(verticalParallelGroup)
    );
}
 
源代码12 项目: freecol   文件: FreeColFileChooserUI.java
@Override
protected void addControlButtons() {
    JPanel buttonPanel = getButtonPanel();
    Component[] buttons = buttonPanel.getComponents();
    buttonPanel.removeAll();
    for (int i=buttons.length-1; i>=0; i--) {
        buttonPanel.add(buttons[i]);
    }
    super.addControlButtons();
}
 
源代码13 项目: BowlerStudio   文件: BowlerCamPanel.java
private void updateImage(BufferedImage imageUpdate, JPanel p){
	if(imageUpdate ==null)
		return;
	p.removeAll();
	JLabel l = new JLabel();
	l.setIcon(new ImageIcon(imageUpdate));
	p.add(l);
	p.invalidate();
}
 
/**
 * Updates the charts.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
	for (int i = 0; i < listOfChartPanels.size(); i++) {
		JPanel panel = listOfChartPanels.get(i);
		panel.removeAll();
		JFreeChart chartOrNull = getModel().getChartOrNull(i);
		if (chartOrNull != null) {
			final ChartPanel chartPanel = new ChartPanel(chartOrNull) {

				private static final long serialVersionUID = -6953213567063104487L;

				@Override
				public Dimension getPreferredSize() {
					return DIMENSION_CHART_PANEL_ENLARGED;
				}
			};
			chartPanel.setPopupMenu(null);
			chartPanel.setBackground(COLOR_TRANSPARENT);
			chartPanel.setOpaque(false);
			chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
			panel.add(chartPanel, BorderLayout.CENTER);

			JPanel openChartPanel = new JPanel(new GridBagLayout());
			openChartPanel.setOpaque(false);

			GridBagConstraints gbc = new GridBagConstraints();
			gbc.anchor = GridBagConstraints.CENTER;
			gbc.fill = GridBagConstraints.NONE;
			gbc.weightx = 1.0;
			gbc.weighty = 1.0;

			JButton openChartButton = new JButton(OPEN_CHART_ACTION);
			openChartButton.setOpaque(false);
			openChartButton.setContentAreaFilled(false);
			openChartButton.setBorderPainted(false);
			openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
			openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
			openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
			openChartButton.setIcon(null);
			Font font = openChartButton.getFont();
			Map attributes = font.getAttributes();
			attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
			openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));

			openChartPanel.add(openChartButton, gbc);

			panel.add(openChartPanel, BorderLayout.SOUTH);
		}
		panel.revalidate();
		panel.repaint();
	}
}
 
源代码15 项目: mzmine3   文件: ChartLogics.java
/**
 * Returns dimensions for limiting factor width or height
 * 
 * @param myChart
 * @return
 */
public static Dimension calcMaxSize(ChartPanel myChart, double chartWidth, double chartHeight) {
  makeChartResizable(myChart);
  // paint on a ghost panel
  JPanel parent = (JPanel) myChart.getParent();
  JPanel p = new JPanel();
  p.removeAll();
  p.add(myChart, BorderLayout.CENTER);
  p.setBounds(myChart.getBounds());
  myChart.paintImmediately(myChart.getBounds());
  p.removeAll();
  parent.add(myChart);

  XYPlot plot = (XYPlot) myChart.getChart().getPlot();
  ChartRenderingInfo info = myChart.getChartRenderingInfo();
  Rectangle2D dataArea = info.getPlotInfo().getDataArea();
  Rectangle2D chartArea = info.getChartArea();

  // calc title space: will be added later to the right plot size
  double titleWidth = chartArea.getWidth() - dataArea.getWidth();
  double titleHeight = chartArea.getHeight() - dataArea.getHeight();

  // calculatig width for max height

  // calc right plot size with axis dim.
  // real plot width is given by factor;
  double realPH = chartHeight - titleHeight;

  // ranges
  ValueAxis domainAxis = plot.getDomainAxis();
  org.jfree.data.Range x = domainAxis.getRange();
  ValueAxis rangeAxis = plot.getRangeAxis();
  org.jfree.data.Range y = rangeAxis.getRange();

  // real plot height can be calculated by
  double realPW = realPH / y.getLength() * x.getLength();

  double width = realPW + titleWidth;
  // if width is higher than given chartWidth then calc height for
  // chartWidth
  if (width > chartWidth) {
    // calc right plot size with axis dim.
    // real plot width is given by factor;
    realPW = chartWidth - titleWidth;

    // real plot height can be calculated by
    realPH = realPW / x.getLength() * y.getLength();

    double height = realPH + titleHeight;
    // Return size
    return new Dimension((int) chartWidth, (int) height);
  } else {
    // Return size
    return new Dimension((int) width, (int) chartHeight);
  }
}
 
源代码16 项目: netbeans   文件: VCSCommitPanel.java
protected void stopProgress() {
    JPanel p = getProgressPanel();
    p.removeAll();
    p.setVisible(false);
}
 
源代码17 项目: old-mzmine3   文件: ChartLogics.java
/**
 * calculates the correct height with multiple iterations Domain and Range axes need to share the
 * same unit (e.g. mm)
 * 
 * @param myChart
 * @param copyToNewPanel
 * @param dataWidth width of data
 * @param axis for width calculation
 * @return
 */
public static double calcHeightToWidth(ChartPanel myChart, double chartWidth,
    double estimatedHeight, int iterations, boolean copyToNewPanel) {
  // if(myChart.getChartRenderingInfo()==null ||
  // myChart.getChartRenderingInfo().getChartArea()==null ||
  // myChart.getChartRenderingInfo().getChartArea().getWidth()==0)
  // result
  double height = estimatedHeight;
  double lastH = height;

  makeChartResizable(myChart);

  // paint on a ghost panel
  JPanel parent = (JPanel) myChart.getParent();
  JPanel p = copyToNewPanel ? new JPanel() : parent;
  if (copyToNewPanel)
    p.add(myChart, BorderLayout.CENTER);
  try {
    for (int i = 0; i < iterations; i++) {
      // paint on ghost panel with estimated height (if copy panel==true)
      myChart.setSize((int) chartWidth, (int) estimatedHeight);
      myChart.paintImmediately(myChart.getBounds());

      XYPlot plot = (XYPlot) myChart.getChart().getPlot();
      ChartRenderingInfo info = myChart.getChartRenderingInfo();
      Rectangle2D dataArea = info.getPlotInfo().getDataArea();
      Rectangle2D chartArea = info.getChartArea();

      // calc title space: will be added later to the right plot size
      double titleWidth = chartArea.getWidth() - dataArea.getWidth();
      double titleHeight = chartArea.getHeight() - dataArea.getHeight();

      // calc right plot size with axis dim.
      // real plot width is given by factor;
      double realPW = chartWidth - titleWidth;

      // ranges
      ValueAxis domainAxis = plot.getDomainAxis();
      org.jfree.data.Range x = domainAxis.getRange();
      ValueAxis rangeAxis = plot.getRangeAxis();
      org.jfree.data.Range y = rangeAxis.getRange();

      // real plot height can be calculated by
      double realPH = realPW / x.getLength() * y.getLength();

      // the real height
      height = realPH + titleHeight;

      // for next iteration
      estimatedHeight = height;
      if ((int) lastH == (int) height)
        break;
      else
        lastH = height;
    }
  } catch (Exception ex) {
    ex.printStackTrace();
  }

  if (copyToNewPanel) {
    // reset to frame
    p.removeAll();
    parent.add(myChart);
  }

  return height;
}
 
private void populateCheckBoxLabelMenuItemListJPanel() {

        JPanel checkBoxLabelMenuItemListJPanel = getCheckBoxLabelMenuItemListJPanel();

        checkBoxLabelMenuItemList.clear();
        checkBoxLabelMenuItemListJPanel.removeAll();

        JPanel traceEventTypesJPanel = new JPanel();
        traceEventTypesJPanel.setLayout(new GridBagLayout());

        JPanel traceEventJPanel = new JPanel();
        traceEventJPanel.setLayout(new GridBagLayout());

        int eventIndex = 0;
        int eventTypeIndex = 0;

        for (TraceEventType traceEventType : traceTableModel.getTraceEventTypeList()) {

            CheckBoxMenuItemPopupEntry<TraceEventKey> cbmipe = traceTableModel.getCheckBoxMenuItem(traceEventType);

            if (cbmipe.isVisible()) {

                GridBagConstraints gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.weightx = 1.0D;
                gbc.weighty = 0.0D;
                gbc.fill = GridBagConstraints.BOTH;
                gbc.anchor = GridBagConstraints.NORTHWEST;
                gbc.insets = new Insets(0, 0, 0, 0);

                CheckBoxLabelMenuItem<TraceEventKey> cblmi;
                cblmi = new CheckBoxLabelMenuItem<TraceEventKey>(cbmipe, true);

                checkBoxLabelMenuItemList.add(cblmi);

                if (traceEventType.isEventType()) {
                    gbc.gridy = eventTypeIndex;
                    traceEventTypesJPanel.add(cblmi, gbc);
                    eventTypeIndex++;
                } else {
                    gbc.gridy = eventIndex;
                    traceEventJPanel.add(cblmi, gbc);
                    eventIndex++;
                }
            }
        }

        Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);

        traceEventJPanel.setBorder(BorderFactory.createTitledBorder(loweredetched, "Events"));

        traceEventTypesJPanel.setBorder(BorderFactory.createTitledBorder(loweredetched, "Event Types"));

        GridBagConstraints gbc1 = new GridBagConstraints();
        gbc1.gridx = 0;
        gbc1.gridy = 0;
        gbc1.weightx = 1.0D;
        gbc1.weighty = 1.0D;
        gbc1.fill = GridBagConstraints.BOTH;
        gbc1.anchor = GridBagConstraints.NORTHWEST;
        gbc1.insets = new Insets(0, 0, 0, 0);

        GridBagConstraints gbc2 = new GridBagConstraints();
        gbc2.gridx = 0;
        gbc2.gridy = 1;
        gbc2.weightx = 1.0D;
        gbc2.weighty = 1.0D;
        gbc2.fill = GridBagConstraints.BOTH;
        gbc2.anchor = GridBagConstraints.NORTHWEST;
        gbc2.insets = new Insets(0, 0, 0, 0);

        checkBoxLabelMenuItemListJPanel.add(traceEventJPanel, gbc1);
        checkBoxLabelMenuItemListJPanel.add(traceEventTypesJPanel, gbc2);

        revalidate();
        repaint();
    }
 
/**
 * Updates the charts.
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
private void updateCharts() {
	for (int i = 0; i < listOfChartPanels.size(); i++) {
		JPanel panel = listOfChartPanels.get(i);
		panel.removeAll();
		final ChartPanel chartPanel = new ChartPanel(getModel().getChartOrNull(i)) {

			private static final long serialVersionUID = -6953213567063104487L;

			@Override
			public Dimension getPreferredSize() {
				return DIMENSION_CHART_PANEL_ENLARGED;
			}
		};
		chartPanel.setPopupMenu(null);
		chartPanel.setBackground(COLOR_TRANSPARENT);
		chartPanel.setOpaque(false);
		chartPanel.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
		panel.add(chartPanel, BorderLayout.CENTER);

		JPanel openChartPanel = new JPanel(new GridBagLayout());
		openChartPanel.setOpaque(false);

		GridBagConstraints gbc = new GridBagConstraints();
		gbc.anchor = GridBagConstraints.CENTER;
		gbc.fill = GridBagConstraints.NONE;
		gbc.weightx = 1.0;
		gbc.weighty = 1.0;

		JButton openChartButton = new JButton(OPEN_CHART_ACTION);
		openChartButton.setOpaque(false);
		openChartButton.setContentAreaFilled(false);
		openChartButton.setBorderPainted(false);
		openChartButton.addMouseListener(enlargeAndHoverAndPopupMouseAdapter);
		openChartButton.setHorizontalAlignment(SwingConstants.LEFT);
		openChartButton.setHorizontalTextPosition(SwingConstants.LEFT);
		openChartButton.setIcon(null);
		Font font = openChartButton.getFont();
		Map attributes = font.getAttributes();
		attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
		openChartButton.setFont(font.deriveFont(attributes).deriveFont(10.0f));

		openChartPanel.add(openChartButton, gbc);

		panel.add(openChartPanel, BorderLayout.SOUTH);
		panel.revalidate();
		panel.repaint();
	}
}
 
源代码20 项目: mzmine2   文件: ChartLogics.java
/**
 * calculates the correct height with multiple iterations Domain and Range axes need to share the
 * same unit (e.g. mm)
 * 
 * @param myChart
 * @param copyToNewPanel
 * @param dataWidth width of data
 * @param axis for width calculation
 * @return
 */
public static double calcHeightToWidth(ChartPanel myChart, double chartWidth,
    double estimatedHeight, int iterations, boolean copyToNewPanel) {
  // if(myChart.getChartRenderingInfo()==null ||
  // myChart.getChartRenderingInfo().getChartArea()==null ||
  // myChart.getChartRenderingInfo().getChartArea().getWidth()==0)
  // result
  double height = estimatedHeight;
  double lastH = height;

  makeChartResizable(myChart);

  // paint on a ghost panel
  JPanel parent = (JPanel) myChart.getParent();
  JPanel p = copyToNewPanel ? new JPanel() : parent;
  if (copyToNewPanel)
    p.add(myChart, BorderLayout.CENTER);
  try {
    for (int i = 0; i < iterations; i++) {
      // paint on ghost panel with estimated height (if copy panel==true)
      myChart.setSize((int) chartWidth, (int) estimatedHeight);
      myChart.paintImmediately(myChart.getBounds());

      XYPlot plot = (XYPlot) myChart.getChart().getPlot();
      ChartRenderingInfo info = myChart.getChartRenderingInfo();
      Rectangle2D dataArea = info.getPlotInfo().getDataArea();
      Rectangle2D chartArea = info.getChartArea();

      // calc title space: will be added later to the right plot size
      double titleWidth = chartArea.getWidth() - dataArea.getWidth();
      double titleHeight = chartArea.getHeight() - dataArea.getHeight();

      // calc right plot size with axis dim.
      // real plot width is given by factor;
      double realPW = chartWidth - titleWidth;

      // ranges
      ValueAxis domainAxis = plot.getDomainAxis();
      org.jfree.data.Range x = domainAxis.getRange();
      ValueAxis rangeAxis = plot.getRangeAxis();
      org.jfree.data.Range y = rangeAxis.getRange();

      // real plot height can be calculated by
      double realPH = realPW / x.getLength() * y.getLength();

      // the real height
      height = realPH + titleHeight;

      // for next iteration
      estimatedHeight = height;
      if ((int) lastH == (int) height)
        break;
      else
        lastH = height;
    }
  } catch (Exception ex) {
    ex.printStackTrace();
  }

  if (copyToNewPanel) {
    // reset to frame
    p.removeAll();
    parent.add(myChart);
  }

  return height;
}