Code Search for Developers
 
 
  

LineCanvas.java from BIRT at Krugle


Show LineCanvas.java syntax highlighted

/***********************************************************************
 * Copyright (c) 2004 Actuate Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Actuate Corporation - initial API and implementation
 ***********************************************************************/

package org.eclipse.birt.chart.ui.swt.composites;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;

/**
 * @author Actuate Corporation
 * 
 */
public class LineCanvas extends Canvas implements PaintListener, FocusListener
{

	int iLineStyle = SWT.LINE_SOLID;

	int iLineWidth = 1;

	boolean isFocusIn = false;

	public LineCanvas( Composite parent, int iStyle, int iLineStyle,
			int iLineWidth )
	{
		super( parent, iStyle );
		this.iLineStyle = iLineStyle;
		this.iLineWidth = iLineWidth;
		this.addPaintListener( this );
		this.addFocusListener( this );
	}

	public int getLineStyle( )
	{
		return this.iLineStyle;
	}

	public void setLineStyle( int iLineStyle )
	{
		this.iLineStyle = iLineStyle;
	}

	public int getLineWidth( )
	{
		return this.iLineWidth;
	}

	public void setLineWidth( int iLineWidth )
	{
		this.iLineWidth = iLineWidth;
	}

	public void paintControl( PaintEvent pe )
	{
		if ( isEnabled( ) && isFocusControl( ) )
		{
			isFocusIn = true;
		}

		Color cForeground = null;
		Color cBackground = null;
		if ( this.isEnabled( ) )
		{
			cForeground = getDisplay( ).getSystemColor( SWT.COLOR_LIST_FOREGROUND );
			cBackground = getDisplay( ).getSystemColor( SWT.COLOR_LIST_BACKGROUND );
		}
		else
		{
			cForeground = getDisplay( ).getSystemColor( SWT.COLOR_DARK_GRAY );
			cBackground = getDisplay( ).getSystemColor( SWT.COLOR_WIDGET_BACKGROUND );
		}

		GC gc = pe.gc;
		if ( isFocusIn )
		{
			gc.setBackground( getDisplay( ).getSystemColor( SWT.COLOR_LIST_SELECTION ) );
			gc.setForeground( getDisplay( ).getSystemColor( SWT.COLOR_LIST_SELECTION_TEXT ) );
		}
		else
		{
			gc.setBackground( cBackground );
			gc.setForeground( cForeground );
		}

		gc.fillRectangle( 0, 0, this.getSize( ).x, this.getSize( ).y );
		gc.setLineStyle( iLineStyle );
		gc.setLineWidth( iLineWidth );
		gc.drawLine( 10,
				this.getSize( ).y / 2,
				this.getSize( ).x - 10,
				this.getSize( ).y / 2 );

	}

	public void setEnabled( boolean bState )
	{
		super.setEnabled( bState );
		redraw( );
	}

	public void focusGained( FocusEvent e )
	{
		isFocusIn = true;

	}

	public void focusLost( FocusEvent e )
	{
		isFocusIn = false;
	}
}



See more files for this project here

BIRT

BIRT is an open source, Eclipse-based reporting system that integrates with your application to produce compelling reports for both web and PDF.

Project homepage: http://www.eclipse.org/birt/phoenix/
Programming language(s): Java,XML
License: gpl2

  AngleSelectorComposite.java
  CTextCombo.java
  CustomChooserComposite.java
  ExtendedPropertyEditorComposite.java
  ExternalizedTextEditorComposite.java
  ExternalizedTextEditorDialog.java
  FillCanvas.java
  FillChooserComposite.java
  FontCanvas.java
  FontDefinitionComposite.java
  FontDefinitionDialog.java
  FormatSpecifierComposite.java
  FormatSpecifierDialog.java
  FormatSpecifierPreview.java
  GanttLineAttributesComposite.java
  GradientEditorDialog.java
  GridAttributesComposite.java
  GroupSortingDialog.java
  HeadStyleAttributeComposite.java
  HeadStyleCanvas.java
  HeadStyleChooserComposite.java
  IAngleChangeListener.java
  ICustomChoice.java
  IconCanvas.java
  ImageDialog.java
  InsetsComposite.java
  IntegerSpinControl.java
  LabelAttributesComposite.java
  LineAttributesComposite.java
  LineCanvas.java
  LineStyleChooserComposite.java
  LineWidthChooserComposite.java
  LocalizedNumberEditorComposite.java
  MarkerEditorComposite.java
  MarkerIconDialog.java
  PaletteEditorComposite.java
  PositiveNegativeColorDialog.java
  SeriesGroupingComposite.java
  TextComboChoiceCanvas.java
  TextEditorComposite.java
  TriggerDataComposite.java
  TriggerEditorComposite.java
  TriggerEditorDialog.java