Java Code Examples for java.awt.Dimension

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/corecomponents/.

Source file: AdvancedConfigurationCleanDialog.java

  23 
vote

/** 
 * Display the given panel on a clean dialog.
 * @param panel the panel to display
 */
public void display(JPanel panel){
  this.setTitle(panel.getName());
  panel.setAlignmentX(Component.CENTER_ALIGNMENT);
  this.add(panel,0);
  this.pack();
  Dimension screenDimension=Toolkit.getDefaultToolkit().getScreenSize();
  int w=this.getSize().width;
  int h=this.getSize().height;
  setLocation((screenDimension.width - w) / 2,(screenDimension.height - h) / 2);
  this.setVisible(true);
}
 

Example 2

From project alg-vis, under directory /src/algvis/gui/.

Source file: Screen.java

  19 
vote

void check_size(){
  Dimension d=getSize();
  if (I == null || d.width != size.width || d.height != size.height) {
    I=createImage(d.width,d.height);
    G=I.getGraphics();
    V.setGraphics((Graphics2D)G,d.width,d.height);
    size=d;
  }
}
 

Example 3

From project Briss, under directory /src/main/java/at/laborg/briss/gui/.

Source file: WrapLayout.java

  18 
vote

/** 
 * Layout the components in the Container using the layout logic of the parent FlowLayout class.
 * @param target the Container using this WrapLayout
 */
@Override public void layoutContainer(Container target){
  Dimension size=preferredLayoutSize(target);
  if (size.equals(preferredLayoutSize)) {
    super.layoutContainer(target);
  }
 else {
    preferredLayoutSize=size;
    Container top=target;
    while (!(top instanceof Window) && top.getParent() != null) {
      top=top.getParent();
    }
    top.validate();
  }
}
 

Example 4

From project ceres, under directory /ceres-glayer/src/test/java/com/bc/ceres/glayer/jaitests/.

Source file: ImageDrawingPerformanceTest.java

  18 
vote

public static void main(String[] args) throws IOException {
  final Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
  final JFrame frame=new JFrame("ImageDrawingPerformanceTest");
  frame.getContentPane().add(new TestCanvas());
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.setSize(screenSize);
  frame.setVisible(true);
}
 

Example 5

From project Chess_1, under directory /src/chess/gui/.

Source file: GridPanel.java

  18 
vote

/** 
 * Calculate the cell size to use given the current viewable region and the the number of rows and columns in the grid. We use the largest cellSize that will fit in the viewable region, bounded to be at least the parameter minSize.
 */
private void recalculateCellSize(int minSize){
  if (numRows == 0 || numCols == 0) {
    cellSize=0;
  }
 else {
    JViewport vp=getEnclosingViewport();
    Dimension viewableSize=(vp != null) ? vp.getSize() : getSize();
    int desiredCellSize=Math.min((viewableSize.height - extraHeight()) / numRows,(viewableSize.width - extraWidth()) / numCols) - 1;
    cellSize=DEFAULT_CELL_SIZE;
    if (cellSize <= desiredCellSize)     while (2 * cellSize <= desiredCellSize)     cellSize*=2;
 else     while (cellSize / 2 >= Math.max(desiredCellSize,MIN_CELL_SIZE))     cellSize/=2;
  }
  revalidate();
}
 

Example 6

From project codjo-data-process, under directory /codjo-data-process-gui/src/main/java/net/codjo/dataprocess/gui/util/.

Source file: GuiUtils.java

  18 
vote

public static void setToLeftSide(Component cp){
  if (cp.getParent() == null) {
    throw new IllegalStateException("L'appel  la m?hode 'setToLeftSide'" + " doit s'effectuer apr? l'ajout au desktop");
  }
  Dimension containerSize=cp.getParent().getSize();
  Dimension frameSize=cp.getSize();
  frameSize.height=containerSize.height;
  frameSize.width=containerSize.width / 4;
  cp.setSize(frameSize);
  cp.setLocation(0,0);
}
 

Example 7

From project codjo-standalone-common, under directory /src/main/java/net/codjo/gui/operation/.

Source file: WaitingWindowManager.java

  18 
vote

/** 
 * Affiche la fen?re d'attente
 */
public void showWaitingWindow(){
  waitingWindow=new WaitingWindow(waitingMessage);
  gexPane.add(waitingWindow);
  Dimension desktopSize=gexPane.getSize();
  Dimension frameSize=waitingWindow.getSize();
  waitingWindow.setLocation(desktopSize.width - frameSize.width,0);
  waitingWindow.setVisible(true);
  try {
    waitingWindow.setSelected(true);
  }
 catch (  java.beans.PropertyVetoException ex) {
    ex.printStackTrace();
  }
}
 

Example 8

From project contribution_eevolution_smart_browser, under directory /client/src/org/compiere/apps/.

Source file: APanel.java

  18 
vote

/** 
 * Set Window Size
 */
private void cmd_winSize(){
  Dimension size=getSize();
  if (!ADialog.ask(m_curWindowNo,this,"WinSizeSet","x=" + size.width + " - y="+ size.height)) {
    setPreferredSize(null);
    SwingUtilities.getWindowAncestor(this).pack();
    size=new Dimension(0,0);
  }
  MWindow win=new MWindow(m_ctx,m_curTab.getAD_Window_ID(),null);
  win.setWindowSize(size);
  win.save();
}
 

Example 9

From project Custom-Salem, under directory /src/haven/.

Source file: MainFrame.java

  18 
vote

private void savewndstate(){
  if (prefs == null) {
    if (getExtendedState() == NORMAL) {
      Dimension dim=p.getSize();
      Utils.setprefc("wndsz",new Coord(dim.width,dim.height));
    }
    Utils.setprefb("wndmax",(getExtendedState() & MAXIMIZED_BOTH) != 0);
  }
}
 

Example 10

From project cytoscape-plugins, under directory /org.openbel.cytoscape.webservice/src/org/openbel/cytoscape/webservice/dialog/.

Source file: SettingsDialog.java

  18 
vote

/** 
 * Constructs the dialog and initializes the UI.
 */
public SettingsDialog(){
  super(Cytoscape.getDesktop(),TITLE,true);
  initUI();
  wsdlURLTxt.setText(cfg.getWSDLURL());
  timeoutSpn.setValue(cfg.getTimeout());
  setTitle(TITLE);
  final Dimension dialogDim=new Dimension(600,300);
  setMinimumSize(dialogDim);
  setSize(dialogDim);
  setPreferredSize(dialogDim);
  setLocationRelativeTo(null);
  setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
  pack();
}
 

Example 11

From project dawn-isencia, under directory /com.isencia.passerelle.commons/src/main/java/com/isencia/util/swing/layout/.

Source file: AbsoluteLayout.java

  18 
vote

/** 
 * Lays out the container in the specified panel.
 * @param parent the component which needs to be laid out
 */
public void layoutContainer(Container parent){
  for (Enumeration<Component> e=constraints.keys(); e.hasMoreElements(); ) {
    Component comp=e.nextElement();
    AbsoluteConstraints ac=constraints.get(comp);
    Dimension size=comp.getPreferredSize();
    int width=ac.getWidth();
    if (width == -1)     width=size.width;
    int height=ac.getHeight();
    if (height == -1)     height=size.height;
    comp.setBounds(ac.x,ac.y,width,height);
  }
}
 

Example 12

From project addis, under directory /application/src/main/java/org/drugis/addis/gui/.

Source file: AddisWindow.java

  17 
vote

private void initPanel(){
  JSplitPane pane=new JSplitPane();
  pane.setBorder(BorderFactory.createEmptyBorder());
  pane.setEnabled(true);
  pane.setOneTouchExpandable(true);
  initLeftPanel();
  pane.setLeftComponent(d_leftPanel);
  d_leftPanel.setMinimumSize(new Dimension(200,d_leftPanel.getMinimumSize().height));
  initRightPanel();
  pane.setRightComponent(d_rightPanel);
  d_rightPanel.setMinimumSize(new Dimension(770,d_rightPanel.getMinimumSize().height));
  add(pane);
}
 

Example 13

From project Agot-Java, under directory /src/main/java/got/test/.

Source file: TestMainUI.java

  17 
vote

/** 
 * @param args
 */
public static void main(String[] args){
  final TestMainUI frame=new TestMainUI();
  Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
  int X=(screen.width / 2) - (960 / 2);
  int Y=(screen.height / 2) - (720 / 2);
  frame.setLocation(X,Y);
  System.out.println(frame.getLocation().getX());
  System.out.println(frame.getLocation().getY());
  frame.addWindowListener(new WindowListener(){
    @Override public void windowActivated(    WindowEvent e){
    }
    @Override public void windowClosed(    WindowEvent e){
    }
    @Override public void windowClosing(    WindowEvent e){
      System.exit(0);
    }
    @Override public void windowDeactivated(    WindowEvent e){
    }
    @Override public void windowDeiconified(    WindowEvent e){
    }
    @Override public void windowIconified(    WindowEvent e){
    }
    @Override public void windowOpened(    WindowEvent e){
    }
  }
);
  frame.add(frame.new MainPanel(frame));
  frame.setVisible(true);
}
 

Example 14

From project Battlepath, under directory /src/interaction/.

Source file: Input.java

  17 
vote

public Input(BFrame frame){
  frame.canvas.addMouseMotionListener(this);
  frame.canvas.addMouseListener(this);
  frame.canvas.addMouseWheelListener(this);
  frame.canvas.addKeyListener(this);
  size=new Dimension();
  size.width=((JPanel)frame.getContentPane()).getWidth();
  size.height=((JPanel)frame.getContentPane()).getHeight();
  pressedKeys=new HashMap<Integer,Remover>();
  keyBuffer=new ArrayList<Character>();
  timer=new Timer();
}
 

Example 15

From project beanmill_1, under directory /src/main/java/com/traxel/lumbermill/desk/.

Source file: FrameControl.java

  17 
vote

@Override public void layout(){
  JInternalFrame frame;
  final List frames;
  final Iterator it;
  final Dimension deskSize;
  final Dimension frameSize;
  int x;
  int y;
  final int width;
  final int height;
  final int totalShrink;
  frames=getActiveFrames();
  if (frames.size() == 0) {
    return;
  }
  deskSize=desktop.getSize();
  totalShrink=INCREMENT * frames.size();
  width=(int)(deskSize.getWidth() - totalShrink);
  height=(int)(deskSize.getHeight() - totalShrink);
  frameSize=new Dimension(width,height);
  x=0;
  y=0;
  it=frames.iterator();
  while (it.hasNext()) {
    frame=(JInternalFrame)it.next();
    try {
      adjustFrame(frame,frameSize,x,y);
      x+=INCREMENT;
      y+=INCREMENT;
    }
 catch (    PropertyVetoException e) {
      e.printStackTrace();
    }
  }
}
 

Example 16

From project Bit4Tat, under directory /Bit4Tat/src/com/Bit4Tat/.

Source file: BitPanel.java

  17 
vote

public SubPanel(String header){
  this.setDoubleBuffered(true);
  this.setBackground(Color.WHITE);
  this.setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
  HeaderLabel headerText=new HeaderLabel(header);
  this.add(Box.createRigidArea(new Dimension(10,0)));
  this.add(Box.createRigidArea(new Dimension(0,10)));
  this.add(headerText);
}
 

Example 17

From project BMach, under directory /src/bmach/ui/gui/components/.

Source file: JAddressPanel.java

  17 
vote

private void initComponents(){
  this.addressLabel=new JLabel("0x00");
  this.addressLabel.setFont(addressFont);
  this.setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
  this.add(Box.createHorizontalStrut(10));
  this.add(addressLabel);
  this.add(Box.createHorizontalStrut(5));
  this.setPreferredSize(new Dimension(50,30));
}
 

Example 18

From project BoneJ, under directory /src/org/doube/util/.

Source file: UsageReporter.java

  17 
vote

/** 
 * Constructor used by singleton pattern. Report variables that relate to single sessions are set here
 */
private UsageReporter(){
  random=new Random();
  if (!Prefs.get(ReporterOptions.OPTOUTKEY,false))   return;
  bonejSession=Prefs.get(ReporterOptions.SESSIONKEY,Integer.toString(new Random().nextInt(1000)));
  int inc=Integer.parseInt(bonejSession);
  inc++;
  bonejSession=Integer.toString(inc);
  Prefs.set(ReporterOptions.SESSIONKEY,inc);
  Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize();
  GraphicsEnvironment ge;
  ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
  int width=0;
  int height=0;
  if (!ge.isHeadlessInstance()) {
    GraphicsDevice[] screens=ge.getScreenDevices();
    for (int i=0; i < screens.length; i++) {
      GraphicsConfiguration[] gc=screens[i].getConfigurations();
      for (      GraphicsConfiguration g : gc) {
        width=Math.max(g.getBounds().x + g.getBounds().width,width);
        height=Math.max(g.getBounds().y + g.getBounds().height,height);
      }
    }
  }
  utmsr="utmsr=" + screenSize.width + "x"+ screenSize.height+ "&";
  utmvp="utmvp=" + width + "x"+ height+ "&";
  utmsc="utmsc=24-bit&";
}
 

Example 19

From project BPMN2-Editor-for-Eclipse, under directory /org.eclipse.bpmn2.modeler.core/src/org/eclipse/bpmn2/modeler/core/utils/.

Source file: FeatureSupport.java

  17 
vote

private static Dimension resizeRecursively(ContainerShape root){
  BaseElement elem=BusinessObjectUtil.getFirstElementOfType(root,BaseElement.class);
  List<Dimension> dimensions=new ArrayList<Dimension>();
  IGaService service=Graphiti.getGaService();
  int foundContainers=0;
  for (  Shape s : root.getChildren()) {
    Object bo=BusinessObjectUtil.getFirstElementOfType(s,BaseElement.class);
    if (checkForResize(elem,s,bo)) {
      foundContainers+=1;
      Dimension d=resizeRecursively((ContainerShape)s);
      if (d != null) {
        dimensions.add(d);
      }
    }
  }
  if (dimensions.isEmpty()) {
    GraphicsAlgorithm ga=root.getGraphicsAlgorithm();
    for (    Shape s : root.getChildren()) {
      GraphicsAlgorithm childGa=s.getGraphicsAlgorithm();
      if (childGa instanceof Text) {
        s.getGraphicsAlgorithm().setHeight(ga.getHeight());
      }
 else       if (childGa instanceof Polyline) {
        Polyline line=(Polyline)childGa;
        Point firstPoint=line.getPoints().get(0);
        Point newPoint=service.createPoint(firstPoint.getX(),ga.getHeight());
        line.getPoints().set(1,newPoint);
      }
    }
    return new Dimension(ga.getWidth(),ga.getHeight());
  }
  if (foundContainers > 0) {
    return resize(root);
  }
  return getMaxDimension(dimensions);
}
 

Example 20

From project Calendar-Application, under directory /calendar/.

Source file: Calindrom.java

  17 
vote

public Calindrom(String title) throws Exception {
  super(title);
  Data.Init();
  m_calendar=new CalendarPanel(this);
  getContentPane().add(m_calendar);
  setMinimumSize(new Dimension(Calindrom.MIN_WIDTH,Calindrom.MIN_HEIGHT));
  setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  try {
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
  }
 catch (  Exception e) {
    System.out.println("Error setting native LAF: " + e);
  }
}
 

Example 21

From project CBCJVM, under directory /cbc/CBCJVM/src/cbccore/display/.

Source file: SimulatedFramebuffer.java

  17 
vote

public SimulatedFramebuffer(String name){
  window.setMinimumSize(new Dimension(320,240));
  window.setPreferredSize(new Dimension(320,240));
  window.setMaximumSize(new Dimension(320,240));
  window.setVisible(true);
}
 

Example 22

From project Cinch, under directory /example/com/palantir/ptoss/cinch/example/dynamic/.

Source file: DynamicControls.java

  17 
vote

private void initializeInterface(){
  JPanel toPanel=new JPanel(new BorderLayout());
  toPanel.add(new JLabel("Count"),BorderLayout.WEST);
  slider.setPaintLabels(true);
  slider.setLabelTable(slider.createStandardLabels(1));
  slider.setSnapToTicks(true);
  toPanel.add(slider,BorderLayout.CENTER);
  panel.setLayout(new BorderLayout());
  panel.add(toPanel,BorderLayout.NORTH);
  checkboxPanel.setLayout(new BoxLayout(checkboxPanel,BoxLayout.Y_AXIS));
  checkboxPanel.setPreferredSize(new Dimension(200,300));
  panel.add(checkboxPanel,BorderLayout.CENTER);
  panel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
}
 

Example 23

From project Clotho-Core, under directory /ClothoApps/PluginManager/src/org/clothocore/tool/pluginmanager/gui/.

Source file: StackLayout.java

  17 
vote

public Dimension preferredLayoutSize(Container parent){
synchronized (parent.getTreeLock()) {
    int width=0;
    int height=0;
    for (    Component comp : components) {
      Dimension size=comp.getPreferredSize();
      width=Math.max(size.width,width);
      height=Math.max(size.height,height);
    }
    Insets insets=parent.getInsets();
    width+=insets.left + insets.right;
    height+=insets.top + insets.bottom;
    return new Dimension(width,height);
  }
}
 

Example 24

From project codjo-broadcast, under directory /codjo-broadcast-gui/src/main/java/net/codjo/broadcast/gui/selector/.

Source file: BroadcastSelectorDetailWindow.java

  17 
vote

public BroadcastSelectorDetailWindow(){
  super("Requ?e de s?ection pour l'export",true,true,true,true);
  selectorColumns.setBackground(new JPanel().getBackground());
  selectorColumns.setName("selectorColumns");
  getContentPane().add(mainPanel);
  setPreferredSize(new Dimension(500,300));
}
 

Example 25

From project codjo-segmentation, under directory /codjo-segmentation-gui/src/main/java/net/codjo/segmentation/gui/exportParam/.

Source file: ExportParametersGui.java

  17 
vote

public ExportParametersGui(){
  super("Export de param?rage",true,true,true,true);
  initNames();
  initListeners();
  directoryPathField.getDirectoryNameField().setEditable(true);
  setContentPane(mainPanel);
  setGlassPane(waitingPanel);
  setPreferredSize(new Dimension(800,150));
}
 

Example 26

From project dawn-common, under directory /org.dawb.hdf5/src/ncsa/hdf/view/.

Source file: DefaultImageView.java

  17 
vote

private void zoomTo(float zf){
  if (zf > 8)   zf=8;
 else   if (zf < 0.125)   zf=0.125f;
  if (zoomFactor == zf)   return;
  zoomFactor=zf;
  Dimension imageSize=new Dimension((int)(imageComponent.originalSize.width * zoomFactor),(int)(imageComponent.originalSize.height * zoomFactor));
  this.invalidate();
  imageComponent.invalidate();
  imageComponent.setImageSize(imageSize);
  this.validate();
  if ((zoomFactor > 0.99) && (zoomFactor < 1.01)) {
    setTitle(frameTitle);
  }
 else {
    setTitle(frameTitle + " - " + 100 * zoomFactor + "%");
  }
}
 

Example 27

From project codjo-control, under directory /codjo-control-gui/src/main/java/net/codjo/control/gui/plugin/.

Source file: DefaultQuarantineDetailWindow.java

  16 
vote

public DefaultQuarantineDetailWindow(DetailDataSource dataSource) throws RequestException {
  super("",true,true,true,true);
  guiContext=dataSource.getGuiContext();
  TranslationNotifier translationNotifier=retrieveTranslationNotifier(guiContext);
  this.guiData=(QuarantineGuiData)guiContext.getProperty(DefaultQuarantineWindow.QUARANTINE_GUI_DATA);
  this.dataSource=dataSource;
  this.mainTabbedPane.setName("TabbedPane");
  final DetailData detailData=guiData.getDetail();
  this.setTitle(detailData.getTitle());
  this.setPreferredSize(new Dimension(detailData.getWindowWidth(),detailData.getWindowHeight()));
  translationNotifier.addInternationalizableContainer(this);
  declareFields(dataSource);
  declareErrorFields();
  dataSource.load();
  initButtonPanel();
  addForceButton();
  if (dataSource.getLoadResult() != null) {
    dataSource.addDataSourceListener(new DataSourceAdapter(){
      @Override public void beforeSaveEvent(      DataSourceEvent event){
        updateErrorType();
      }
    }
);
  }
  addFormPanels();
}
 

Example 28

From project codjo-imports, under directory /codjo-imports-gui/src/main/java/net/codjo/imports/gui/.

Source file: ImportWindow.java

  16 
vote

private void jbInit(){
  TitledBorder titledBorder1=new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(134,134,134)),"Fichiers");
  TitledBorder titledBorder2=new TitledBorder(BorderFactory.createEtchedBorder(Color.white,new Color(134,134,134)),"Sections");
  this.getContentPane().setLayout(borderLayout3);
  filesPanel.setLayout(borderLayout1);
  this.setClosable(true);
  this.setResizable(true);
  this.setIconifiable(true);
  this.setMaximizable(true);
  this.setTitle("Fichiers / Sections");
  this.setPreferredSize(new Dimension(500,500));
  sectionsPanel.setLayout(borderLayout2);
  filesPanel.setBorder(titledBorder1);
  filesPanel.setMinimumSize(new Dimension(100,100));
  filesPanel.setPreferredSize(new Dimension(300,300));
  sectionsPanel.setBorder(titledBorder2);
  sectionsPanel.setMinimumSize(new Dimension(100,100));
  sectionsPanel.setPreferredSize(new Dimension(300,300));
  filesPanel.add(scrollPane,BorderLayout.CENTER);
  filesPanel.add(filesToolBar,BorderLayout.SOUTH);
  sectionsPanel.add(scrollPane1,BorderLayout.CENTER);
  sectionsPanel.add(contentsToolBar,BorderLayout.SOUTH);
  scrollPane1.getViewport().add(sectionsTable,null);
  scrollPane.getViewport().add(filesTable,null);
  JSplitPane splitPane=new JSplitPane(JSplitPane.VERTICAL_SPLIT,true,filesPanel,sectionsPanel);
  splitPane.setResizeWeight(0.3);
  splitPane.setDividerLocation(200);
  this.getContentPane().add(splitPane,BorderLayout.CENTER);
}
 

Example 29

From project com.idega.content, under directory /src/java/com/idega/content/themes/helpers/business/impl/.

Source file: ThemesHelperImpl.java

  16 
vote

/** 
 * Generates big and small previews for single theme
 * @param theme
 * @param useDraft
 * @param isJpg
 * @param quality
 * @return true - success, false - failure
 */
public boolean generatePreviewsForTheme(Theme theme,boolean useDraft,boolean isJpg,float quality){
  String url=new StringBuilder(getFullWebRoot()).append(useDraft ? theme.getLinkToDraft() : theme.getLinkToSkeleton()).toString();
  String smallPreviewName=new StringBuffer(theme.getName()).append(ThemesConstants.THEME_SMALL_PREVIEW).toString();
  List<Dimension> dimensions=Arrays.asList(new Dimension(ThemesConstants.SMALL_PREVIEW_WIDTH,ThemesConstants.SMALL_PREVIEW_HEIGHT));
  ImageGenerator imageGenerator=getImageGenerator(null);
  List<BufferedImage> images=imageGenerator.generatePreviews(url,dimensions,isJpg,quality);
  if (images == null) {
    return false;
  }
  String extension=imageGenerator.getFileExtension();
  String mimeType=new StringBuffer(ThemesConstants.DEFAULT_MIME_TYPE).append(extension).toString();
  smallPreviewName=new StringBuffer(smallPreviewName).append(CoreConstants.DOT).append(extension).toString();
  BufferedImage image=null;
  InputStream stream=null;
  IWSlideService slide=getSlideService();
  for (int i=0; i < images.size(); i++) {
    image=images.get(i);
    stream=imageGenerator.getImageInputStream(image,extension);
    try {
      if (slide.uploadFileAndCreateFoldersFromStringAsRoot(theme.getLinkToBaseAsItIs(),smallPreviewName,stream,mimeType,true)) {
        theme.setLinkToSmallPreview(smallPreviewName);
      }
    }
 catch (    Exception e) {
      e.printStackTrace();
      return false;
    }
 finally {
      IOUtil.closeInputStream(stream);
    }
  }
  return true;
}
 

Example 30

From project des, under directory /daemon/lib/apache-log4j-1.2.16/contribs/CekiGulcu/.

Source file: AppenderTable.java

  16 
vote

static public void main(String[] args){
  if (args.length != 2) {
    System.err.println("Usage: java AppenderTable bufferSize runLength\n" + "  where bufferSize is the size of the cyclic buffer in the TableModel\n" + "  and runLength is the total number of elements to add to the table in\n"+ "  this test run.");
    return;
  }
  JFrame frame=new JFrame("JTableAppennder test");
  Container container=frame.getContentPane();
  AppenderTable tableAppender=new AppenderTable();
  int bufferSize=Integer.parseInt(args[0]);
  AppenderTableModel model=new AppenderTableModel(bufferSize);
  tableAppender.setModel(model);
  int runLength=Integer.parseInt(args[1]);
  JScrollPane sp=new JScrollPane(tableAppender);
  sp.setPreferredSize(new Dimension(250,80));
  container.setLayout(new BoxLayout(container,BoxLayout.X_AXIS));
  container.add(sp);
  JButton button=new JButton("ADD");
  container.add(button);
  button.addActionListener(new JTableAddAction(tableAppender));
  frame.setSize(new Dimension(500,300));
  frame.setVisible(true);
  long before=System.currentTimeMillis();
  int i=0;
  while (i++ < runLength) {
    LoggingEvent event=new LoggingEvent("x",logger,Level.ERROR,"Message " + i,null);
    tableAppender.doAppend(event);
  }
  long after=System.currentTimeMillis();
  long totalTime=(after - before);
  System.out.println("Total time :" + totalTime + " milliseconds for "+ "runLength insertions.");
  System.out.println("Average time per insertion :" + (totalTime * 1000 / runLength) + " micro-seconds.");
}
 

Example 31

From project core_4, under directory /impl/src/main/java/org/richfaces/renderkit/html/.

Source file: BaseGradient.java

  15 
vote

/** 
 * @param g2d
 * @param dim
 */
protected void paintGradient(Graphics2D g2d,Dimension dim){
  if (headerBackgroundColor != null && headerGradientColor != null && gradientType != null) {
    BiColor biColor=new GradientType.BiColor(headerBackgroundColor,headerGradientColor);
    BiColor firstLayer=gradientType.getFirstLayerColors(biColor);
    BiColor secondLayer=gradientType.getSecondLayerColors(biColor);
    if (horizontal) {
      g2d.transform(new AffineTransform(0,1,1,0,0,0));
      dim.setSize(dim.height,dim.width);
    }
    int localGradientHeight=this.gradientHeight;
    if (localGradientHeight < 0) {
      localGradientHeight=dim.height;
    }
    Rectangle2D rect=new Rectangle2D.Float(0,0,dim.width,dim.height);
    drawGradient(g2d,rect,firstLayer,localGradientHeight);
    int smallGradientHeight=localGradientHeight / 2;
    rect=new Rectangle2D.Float(0,0,dim.width,smallGradientHeight);
    drawGradient(g2d,rect,secondLayer,smallGradientHeight);
  }
}