// * This code is licensed under:
// * jeHEP License, Version 1.0
// * - for license details see http://jehep.sourceforge.net/license.html
// *
// * Copyright (c) 2005 by S.Chekanov (chekanov@mail.desy.de).
// * All rights reserved.
package japlot;
import japlot.jaxodraw.*;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
/**
* Show information about jHplot. Also keeps some global variables.
*
* @author S.Chekanov
*
*/
// keep current data
public class Global {
public static JLabel statusbar;
public static int sizeX;
public static int sizeY;
public final static int SECONDS = 3000;
public static Timer timer;
private static boolean firstTime = true;
public static void init(int sizex, int sizey) {
sizeX = sizex;
sizeY = sizey;
statusbar = new JLabel("jHPlot is ready");
statusbar.setFont(new Font("Serif", Font.PLAIN, 12));
timer = new Timer(SECONDS, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
statusbar.setText(" ");
timer.stop();
}
});
timer.setRepeats(false);
}
// moving to NDC
public static float toX(int x) {
return (float) x / (float) sizeX;
}
public static float toY(int y) {
return (float) y / (float) sizeY;
}
// moving from NDC
public static int fromX(float x) {
return (int) (x * sizeX);
}
// moving from NDC
public static int fromY(float y) {
return (int) (y * sizeY);
}
/**
* Show a text on status bar for 5 sec.
*
* @param text
* Text
*/
public static void showStatusBarText(String text) {
statusbar.setText(text);
if (timer.isRunning()) {
timer.restart();
} else {
timer.start();
}
}
/**
* Show a text on status bar permanently.
*
* @param text
* Text
*/
public static void showMessage(String text) {
statusbar.setText(text);
}
}
Ads help maintain this website.