All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cobraparser.html.renderer.BaseControl Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
/*
    GNU LESSER GENERAL PUBLIC LICENSE
    Copyright (C) 2006 The Lobo Project

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

    Contact info: [email protected]
 */
/*
 * Created on Oct 23, 2005
 */
package org.cobraparser.html.renderer;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.util.logging.Logger;

import javax.swing.JComponent;

import org.cobraparser.html.domimpl.HTMLElementImpl;

import cz.vutbr.web.css.CSSProperty.VerticalAlign;

abstract class BaseControl extends JComponent implements UIControl {
  private static final long serialVersionUID = 7061225345785659580L;
  private static final Logger logger = Logger.getLogger(BaseControl.class.getName());
  protected static final Dimension ZERO_DIMENSION = new Dimension(0, 0);
  protected final HTMLElementImpl controlElement;
  protected RUIControl ruicontrol;

  /**
   * @param context
   */
  public BaseControl(final HTMLElementImpl modelNode) {
    this.controlElement = modelNode;
  }

  public Component getComponent() {
    return this;
  }

  public void setRUIControl(final RUIControl ruicontrol) {
    this.ruicontrol = ruicontrol;
  }

  public VerticalAlign getVAlign() {
    return VerticalAlign.BASELINE;
  }

  /**
   * Method invoked when image changes size. It's expected to be called outside
   * the GUI thread.
   */
  protected void invalidateAndRepaint() {
    final RUIControl rc = this.ruicontrol;
    if (rc == null) {
      logger.severe("invalidateAndPaint(): RUIControl not set.");
      return;
    }
    if (rc.isValid()) {
      rc.relayout();
    }
  }

  /*
   * (non-Javadoc)
   *
   * @see org.xamjwg.html.renderer.UIControl#getBackgroundColor()
   */
  public Color getBackgroundColor() {
    return this.getBackground();
  }

  public void reset(final int availWidth, final int availHeight) {
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy