Example usage for java.text NumberFormat getNumberInstance

List of usage examples for java.text NumberFormat getNumberInstance

Introduction

In this page you can find the example usage for java.text NumberFormat getNumberInstance.

Prototype

public static final NumberFormat getNumberInstance() 

Source Link

Document

Returns a general-purpose number format for the current default java.util.Locale.Category#FORMAT FORMAT locale.

Usage

From source file:com.google.android.apps.santatracker.rocketsleigh.EndGameActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_end_game);

    TextView sv = (TextView) findViewById(R.id.score_text);
    final long score = getIntent().getLongExtra("score", 0);
    sv.setText(NumberFormat.getNumberInstance().format(score));

    mSignIn = findViewById(R.id.play_again_gplus);

    // App Invites
    mInviteFragment = AppInvitesFragment.getInstance(this);
    findViewById(R.id.invite).setOnClickListener(new View.OnClickListener() {
        @Override//from  www. j a  v a  2  s. c o m
        public void onClick(View v) {
            mInviteFragment.sendGameInvite(getString(R.string.rocket), "rocketsleigh", (int) score);
        }
    });

    // App Measurement
    mMeasurement = FirebaseAnalytics.getInstance(this);
    MeasurementManager.recordScreenView(mMeasurement, getString(R.string.analytics_screen_rocket_endgame));

    if (TvUtil.isTv(this)) {
        mSignIn.setVisibility(View.GONE);
        mPlayAgain = findViewById(R.id.play_again);
        findViewById(R.id.exit).setVisibility(View.GONE);
        findViewById(R.id.invite).setVisibility(View.GONE);
        findViewById(R.id.popup_view).setVisibility(View.GONE);
    } else {
        mGamesFragment = PlayGamesFragment.getInstance(this, this);

        if (mGamesFragment.isSignedIn()) {
            mSignIn.setVisibility(View.GONE);
            updateAchievementsAndLeaderboard();
        } else {
            mSignIn.setVisibility(View.VISIBLE);
        }
    }
}

From source file:no.abmu.abmstatistikk.annualstatistic.service.VideregaaendeSkoleBibValidator.java

public void computeValidateFieldKeys() {
    NumberFormat fieldNameFormater = NumberFormat.getNumberInstance();
    fieldNameFormater.setMinimumIntegerDigits(3);
    Set fieldKeys = new HashSet();
    int i;/*from  w ww  .  ja v a  2s  .c o m*/

    switch (pageNumber) {
    case 1:
        break;
    case 2:
        fieldKeys.add(fieldNameFormater.format((long) 226));
        for (i = 405; i <= 409; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        break;
    case 3:
        for (i = 19; i <= 30; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 34; i <= 36; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 40; i <= 42; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 49; i <= 51; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 55; i <= 60; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 64; i <= 66; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 202; i <= 204; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        break;
    case 4:
        for (i = 69; i <= 70; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        fieldKeys.add(fieldNameFormater.format((long) 80));
        fieldKeys.add(fieldNameFormater.format((long) 82));
        for (i = 84; i <= 86; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 91; i <= 96; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        fieldKeys.add(fieldNameFormater.format((long) 486));
        break;
    case 5:
        for (i = 102; i <= 104; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 108; i <= 119; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 148; i <= 150; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 167; i <= 168; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        fieldKeys.add(fieldNameFormater.format((long) 183));
        fieldKeys.add(fieldNameFormater.format((long) 185));
        break;
    case 6:
        for (i = 211; i <= 214; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        for (i = 225; i <= 229; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        break;
    case 7:
        fieldKeys.add(fieldNameFormater.format((long) 244));
        fieldKeys.add(fieldNameFormater.format((long) 247));
        fieldKeys.add(fieldNameFormater.format((long) 250));
        fieldKeys.add(fieldNameFormater.format((long) 253));
        for (i = 381; i <= 382; i++) {
            fieldKeys.add(fieldNameFormater.format((long) i));
        }
        break;
    default:
        break;
    }
    logger.debug("Keys to validate: " + fieldKeys);
    setValidateFieldKeys(fieldKeys);

}

From source file:picocash.model.impl.Money.java

@Override
public String toString() {
    double result = (double) value / 100;
    NumberFormat numberFormat = NumberFormat.getNumberInstance();
    numberFormat.setMinimumFractionDigits(2);
    numberFormat.setMaximumFractionDigits(2);
    return numberFormat.format(result);
}

From source file:uk.org.funcube.fcdw.service.PredictorService.java

public SatellitePosition get(Long catnum, Date instant, GroundStationPosition groundStationPosition) {

    SatellitePosition position = null;//from ww w .j a v  a  2s . c  o m

    List<TleEntity> tleEntities = tleDao.findByCatnum(catnum);

    if (!tleEntities.isEmpty()) {
        final TleEntity tleEntity = tleEntities.get(0);
        final TLE tle = new TLE(tleEntity.getCatnum(), tleEntity.getName(), tleEntity.getSetnum(),
                tleEntity.getYear(), tleEntity.getRefepoch(), tleEntity.getIncl(), tleEntity.getRaan(),
                tleEntity.getEccn(), tleEntity.getArgper(), tleEntity.getMeanan(), tleEntity.getMeanmo(),
                tleEntity.getDrag(), tleEntity.getNddot6(), tleEntity.getBstar(), tleEntity.getOrbitnum(),
                tleEntity.getEpoch(), tleEntity.getXndt2o(), tleEntity.getXincl(), tleEntity.getXnodeo(),
                tleEntity.getEo(), tleEntity.getOmega(), tleEntity.getMo(), tleEntity.getXno(),
                tleEntity.isDeepspace(), tleEntity.getCreateddate());

        Satellite satellite = SatelliteFactory.createSatellite(tle);

        satellite.calculateSatelliteVectors(instant);
        satellite.calculateSatelliteGroundTrack();

        SatPos satPos = satellite.calculateSatPosForGroundStation(groundStationPosition);

        final NumberFormat numberFormat = NumberFormat.getNumberInstance();
        numberFormat.setMaximumFractionDigits(2);

        position = new SatellitePosition(numberFormat.format(satPos.getLatitude() / (Math.PI * 2.0) * 360),
                numberFormat.format(satPos.getLongitude() / (Math.PI * 2.0) * 360),
                satPos.isEclipsed() ? "yes" : "no", numberFormat.format(satPos.getEclipseDepth()),
                satPos.isAboveHorizon());
    }

    return position;
}

From source file:DecimalFormatDemo.java

public DecimalFormatDemo() {

    availableLocales = new LocaleGroup();
    inputFormatter = NumberFormat.getNumberInstance();

    String[] patternExamples = { "##.##", "###,###.##", "##,##,##.##", "#", "000,000.0000", "##.0000",
            "'hello'###.##" };

    currentPattern = patternExamples[0];

    // Set up the UI for entering a number.
    JLabel numberLabel = new JLabel("Enter the number to format:");
    numberLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JTextField numberField = new JTextField();
    numberField.setEditable(true);//from w  w w.  j  a v a 2 s.  com
    numberField.setAlignmentX(Component.LEFT_ALIGNMENT);
    NumberListener numberListener = new NumberListener();
    numberField.addActionListener(numberListener);

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");
    patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setSelectedIndex(0);
    patternList.setEditable(true);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    PatternListener patternListener = new PatternListener();
    patternList.addActionListener(patternListener);

    // Set up the UI for selecting a locale.
    JLabel localeLabel = new JLabel("Select a Locale from the list:");
    localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox localeList = new JComboBox(availableLocales.getStrings());
    localeList.setSelectedIndex(0);
    localeList.setAlignmentX(Component.LEFT_ALIGNMENT);
    LocaleListener localeListener = new LocaleListener();
    localeList.addActionListener(localeListener);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Result", JLabel.LEFT);
    resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setAlignmentX(Component.LEFT_ALIGNMENT);
    result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything
    JPanel numberPanel = new JPanel();
    numberPanel.setLayout(new GridLayout(0, 1));
    numberPanel.add(numberLabel);
    numberPanel.add(numberField);

    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternPanel.add(patternList);

    JPanel localePanel = new JPanel();
    localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS));
    localePanel.add(localeLabel);
    localePanel.add(localeList);

    JPanel resultPanel = new JPanel();
    resultPanel.setLayout(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    numberPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    localePanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT);

    add(numberPanel);
    add(Box.createVerticalStrut(10));
    add(patternPanel);
    add(Box.createVerticalStrut(10));
    add(localePanel);
    add(Box.createVerticalStrut(10));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
    numberField.setText(result.getText());

}

From source file:edu.ucla.stat.SOCR.motionchart.MotionToolTipGenerator.java

/**
 * Creates a new tool tip generator using default number formatters for the
 * x, y and z-values./*from ww  w. j a va  2s  .c om*/
 */
public MotionToolTipGenerator() {
    this(DEFAULT_TOOL_TIP_FORMAT, NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance(),
            NumberFormat.getNumberInstance(), NumberFormat.getNumberInstance(),
            NumberFormat.getNumberInstance());
}

From source file:kien.activities.DistrictAcitivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_viewdistrict);
    TextView tvPopulation = (TextView) findViewById(R.id.tvPopulation);
    TextView tvArea = (TextView) findViewById(R.id.tvArea);
    GridView gvDistrict = (GridView) findViewById(R.id.gvDistrict);
    ivBack = (ImageView) findViewById(R.id.ivBack);
    ivBack.setOnClickListener(new View.OnClickListener() {
        @Override/* w ww  .j a  va 2 s  .  c o  m*/
        public void onClick(View v) {
            onBackPressed();
        }
    });
    TextView tvNameProvince = (TextView) findViewById(R.id.tvNameProvince);

    Intent myIntent = getIntent();
    int id = myIntent.getIntExtra("id", 0);

    dataBaseHelper = new DataBaseHelper(this);
    try {
        dataBaseHelper.isCreatedDatabase();
    } catch (IOException e) {

    }

    int population = dataBaseHelper.getPopulationProvince(id);
    float area = dataBaseHelper.getAreaProvince(id);
    NumberFormat numberFormat = NumberFormat.getNumberInstance();
    numberFormat.format(population);
    Log.e("NUMBER", area + "");
    tvPopulation.setText(numberFormat.format(population) + " ng?i");
    tvArea.setText(area + "  km2");

    listLicense = new ArrayList<License>();
    listLicense = dataBaseHelper.getListDistrict(id);
    adapterLicense = new AdapterLicense(this, R.layout.fragment_license, listLicense, this);
    gvDistrict.setAdapter(adapterLicense);
    localAddress = dataBaseHelper.getAddressLocal(id);
    tvNameProvince.setText(localAddress + "");
    //add Map;
    //        mMapFragment = MapFragment.newInstance();
    //        FragmentTransaction fragmentTransaction =
    //                getFragmentManager().beginTransaction();
    //        fragmentTransaction.add(R.id.map, mMapFragment);
    //        fragmentTransaction.commit();
    //        mMapFragment.getMapAsync(this);
    //        GoogleMapOptions googleMapOptions = new GoogleMapOptions();
    //        googleMapOptions.mapType(GoogleMap.MAP_TYPE_HYBRID).compassEnabled(true).zoomControlsEnabled(false);

    //googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(HANOI, 10));
    //googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);

    latlongAdress = dataBaseHelper.getLatLong(id);

    MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
    googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latlongAdress, 9));
    Log.e("TEST", latlongAdress + " address");
    Log.e("TEST", googleMap + "google");
    //GoogleMap googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
    googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    googleMap.getUiSettings().setZoomControlsEnabled(true);
    googleMap.setMyLocationEnabled(true);

}

From source file:guineu.util.dialogs.AxesSetupDialog.java

/**
 * Constructor//from ww  w  .  j  av  a2s. co  m
 */
public AxesSetupDialog(XYPlot plot) {

    // Make dialog modal
    super(GuineuCore.getDesktop().getMainFrame(), true);

    xAxis = plot.getDomainAxis();
    yAxis = plot.getRangeAxis();

    NumberFormat defaultFormatter = NumberFormat.getNumberInstance();
    NumberFormat xAxisFormatter = defaultFormatter;
    if (xAxis instanceof NumberAxis) {
        xAxisFormatter = ((NumberAxis) xAxis).getNumberFormatOverride();
    }
    NumberFormat yAxisFormatter = defaultFormatter;
    if (yAxis instanceof NumberAxis) {
        yAxisFormatter = ((NumberAxis) yAxis).getNumberFormatOverride();
    }

    // Create labels and fields
    JLabel lblXTitle = new JLabel(xAxis.getLabel());
    JLabel lblXAutoRange = new JLabel("Auto range");
    JLabel lblXMin = new JLabel("Minimum");
    JLabel lblXMax = new JLabel("Maximum");
    JLabel lblXAutoTick = new JLabel("Auto tick size");
    JLabel lblXTick = new JLabel("Tick size");

    JLabel lblYTitle = new JLabel(yAxis.getLabel());
    JLabel lblYAutoRange = new JLabel("Auto range");
    JLabel lblYMin = new JLabel("Minimum");
    JLabel lblYMax = new JLabel("Maximum");
    JLabel lblYAutoTick = new JLabel("Auto tick size");
    JLabel lblYTick = new JLabel("Tick size");

    checkXAutoRange = new JCheckBox();
    checkXAutoRange.addActionListener(this);
    checkXAutoTick = new JCheckBox();
    checkXAutoTick.addActionListener(this);
    fieldXMin = new JFormattedTextField(xAxisFormatter);
    fieldXMax = new JFormattedTextField(xAxisFormatter);
    fieldXTick = new JFormattedTextField(xAxisFormatter);

    checkYAutoRange = new JCheckBox();
    checkYAutoRange.addActionListener(this);
    checkYAutoTick = new JCheckBox();
    checkYAutoTick.addActionListener(this);
    fieldYMin = new JFormattedTextField(yAxisFormatter);
    fieldYMax = new JFormattedTextField(yAxisFormatter);
    fieldYTick = new JFormattedTextField(yAxisFormatter);

    // Create a panel for labels and fields
    JPanel pnlLabelsAndFields = new JPanel(new GridLayout(0, 2));

    pnlLabelsAndFields.add(lblXTitle);
    pnlLabelsAndFields.add(new JPanel());
    pnlLabelsAndFields.add(lblXAutoRange);
    pnlLabelsAndFields.add(checkXAutoRange);
    pnlLabelsAndFields.add(lblXMin);
    pnlLabelsAndFields.add(fieldXMin);
    pnlLabelsAndFields.add(lblXMax);
    pnlLabelsAndFields.add(fieldXMax);
    if (xAxis instanceof NumberAxis) {
        pnlLabelsAndFields.add(lblXAutoTick);
        pnlLabelsAndFields.add(checkXAutoTick);
        pnlLabelsAndFields.add(lblXTick);
        pnlLabelsAndFields.add(fieldXTick);
    }

    // Empty row
    pnlLabelsAndFields.add(new JPanel());
    pnlLabelsAndFields.add(new JPanel());

    pnlLabelsAndFields.add(lblYTitle);
    pnlLabelsAndFields.add(new JPanel());
    pnlLabelsAndFields.add(lblYAutoRange);
    pnlLabelsAndFields.add(checkYAutoRange);
    pnlLabelsAndFields.add(lblYMin);
    pnlLabelsAndFields.add(fieldYMin);
    pnlLabelsAndFields.add(lblYMax);
    pnlLabelsAndFields.add(fieldYMax);
    if (yAxis instanceof NumberAxis) {
        pnlLabelsAndFields.add(lblYAutoTick);
        pnlLabelsAndFields.add(checkYAutoTick);
        pnlLabelsAndFields.add(lblYTick);
        pnlLabelsAndFields.add(fieldYTick);
    }

    // Create buttons
    JPanel pnlButtons = new JPanel();
    btnOK = new JButton("OK");
    btnOK.addActionListener(this);
    btnApply = new JButton("Apply");
    btnApply.addActionListener(this);
    btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(this);

    pnlButtons.add(btnOK);
    pnlButtons.add(btnApply);
    pnlButtons.add(btnCancel);

    // Put everything into a main panel
    JPanel pnlAll = new JPanel(new BorderLayout());
    pnlAll.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    add(pnlAll);

    pnlAll.add(pnlLabelsAndFields, BorderLayout.CENTER);
    pnlAll.add(pnlButtons, BorderLayout.SOUTH);

    pack();

    setTitle("Please set ranges for axes");
    setResizable(false);
    setLocationRelativeTo(GuineuCore.getDesktop().getMainFrame());

    getValuesToControls();

}

From source file:net.sf.mzmine.util.dialogs.AxesSetupDialog.java

/**
 * Constructor/*from w ww.  j  av  a  2s.c o m*/
 */
public AxesSetupDialog(XYPlot plot) {

    // Make dialog modal
    super(MZmineCore.getDesktop().getMainWindow(), true);

    xAxis = plot.getDomainAxis();
    yAxis = plot.getRangeAxis();

    NumberFormat defaultFormatter = NumberFormat.getNumberInstance();
    NumberFormat xAxisFormatter = defaultFormatter;
    if (xAxis instanceof NumberAxis)
        xAxisFormatter = ((NumberAxis) xAxis).getNumberFormatOverride();
    NumberFormat yAxisFormatter = defaultFormatter;
    if (yAxis instanceof NumberAxis)
        yAxisFormatter = ((NumberAxis) yAxis).getNumberFormatOverride();

    // Create labels and fields
    JLabel lblXTitle = new JLabel(xAxis.getLabel());
    JLabel lblXAutoRange = new JLabel("Auto range");
    JLabel lblXMin = new JLabel("Minimum");
    JLabel lblXMax = new JLabel("Maximum");
    JLabel lblXAutoTick = new JLabel("Auto tick size");
    JLabel lblXTick = new JLabel("Tick size");

    JLabel lblYTitle = new JLabel(yAxis.getLabel());
    JLabel lblYAutoRange = new JLabel("Auto range");
    JLabel lblYMin = new JLabel("Minimum");
    JLabel lblYMax = new JLabel("Maximum");
    JLabel lblYAutoTick = new JLabel("Auto tick size");
    JLabel lblYTick = new JLabel("Tick size");

    checkXAutoRange = new JCheckBox();
    checkXAutoRange.addActionListener(this);
    checkXAutoTick = new JCheckBox();
    checkXAutoTick.addActionListener(this);
    fieldXMin = new JFormattedTextField(xAxisFormatter);
    fieldXMax = new JFormattedTextField(xAxisFormatter);
    fieldXTick = new JFormattedTextField(xAxisFormatter);

    checkYAutoRange = new JCheckBox();
    checkYAutoRange.addActionListener(this);
    checkYAutoTick = new JCheckBox();
    checkYAutoTick.addActionListener(this);
    fieldYMin = new JFormattedTextField(yAxisFormatter);
    fieldYMax = new JFormattedTextField(yAxisFormatter);
    fieldYTick = new JFormattedTextField(yAxisFormatter);

    // Create a panel for labels and fields
    JPanel pnlLabelsAndFields = new JPanel(new GridLayout(0, 2));

    pnlLabelsAndFields.add(lblXTitle);
    pnlLabelsAndFields.add(new JPanel());
    pnlLabelsAndFields.add(lblXAutoRange);
    pnlLabelsAndFields.add(checkXAutoRange);
    pnlLabelsAndFields.add(lblXMin);
    pnlLabelsAndFields.add(fieldXMin);
    pnlLabelsAndFields.add(lblXMax);
    pnlLabelsAndFields.add(fieldXMax);
    if (xAxis instanceof NumberAxis) {
        pnlLabelsAndFields.add(lblXAutoTick);
        pnlLabelsAndFields.add(checkXAutoTick);
        pnlLabelsAndFields.add(lblXTick);
        pnlLabelsAndFields.add(fieldXTick);
    }

    // Empty row
    pnlLabelsAndFields.add(new JPanel());
    pnlLabelsAndFields.add(new JPanel());

    pnlLabelsAndFields.add(lblYTitle);
    pnlLabelsAndFields.add(new JPanel());
    pnlLabelsAndFields.add(lblYAutoRange);
    pnlLabelsAndFields.add(checkYAutoRange);
    pnlLabelsAndFields.add(lblYMin);
    pnlLabelsAndFields.add(fieldYMin);
    pnlLabelsAndFields.add(lblYMax);
    pnlLabelsAndFields.add(fieldYMax);
    if (yAxis instanceof NumberAxis) {
        pnlLabelsAndFields.add(lblYAutoTick);
        pnlLabelsAndFields.add(checkYAutoTick);
        pnlLabelsAndFields.add(lblYTick);
        pnlLabelsAndFields.add(fieldYTick);
    }

    // Create buttons
    JPanel pnlButtons = new JPanel();
    btnOK = new JButton("OK");
    btnOK.addActionListener(this);
    btnApply = new JButton("Apply");
    btnApply.addActionListener(this);
    btnCancel = new JButton("Cancel");
    btnCancel.addActionListener(this);

    pnlButtons.add(btnOK);
    pnlButtons.add(btnApply);
    pnlButtons.add(btnCancel);

    // Put everything into a main panel
    JPanel pnlAll = new JPanel(new BorderLayout());
    pnlAll.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    add(pnlAll);

    pnlAll.add(pnlLabelsAndFields, BorderLayout.CENTER);
    pnlAll.add(pnlButtons, BorderLayout.SOUTH);

    pack();

    setTitle("Please set ranges for axes");
    setResizable(false);
    setLocationRelativeTo(MZmineCore.getDesktop().getMainWindow());

    getValuesToControls();

}

From source file:dr.PlotPanel.java

public PlotPanel(PCADataset dataset) {
    super(null);//from  w  w w  .j av  a  2 s  .  c  o  m

    chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset,
            PlotOrientation.VERTICAL, false, false, false);
    chart.setBackgroundPaint(Color.white);

    setChart(chart);

    // title

    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);
    chart.removeSubtitle(chartTitle);

    // disable maximum size (we don't want scaling)
    setMaximumDrawWidth(Integer.MAX_VALUE);
    setMaximumDrawHeight(Integer.MAX_VALUE);

    // set the plot properties
    plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));

    // set grid properties
    plot.setDomainGridlinePaint(gridColor);
    plot.setRangeGridlinePaint(gridColor);

    // set crosshair (selection) properties
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);

    plot.setForegroundAlpha(dataPointAlpha);

    NumberFormat numberFormat = NumberFormat.getNumberInstance();

    // set the X axis (component 1) properties
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setNumberFormatOverride(numberFormat);

    // set the Y axis (component 2) properties
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setNumberFormatOverride(numberFormat);

    plot.setDataset(dataset);

    spotRenderer = new PlotRenderer(plot, dataset);
    itemLabelGenerator = new PlotItemLabelGenerator();
    spotRenderer.setBaseItemLabelGenerator(itemLabelGenerator);
    spotRenderer.setBaseItemLabelsVisible(true);
    spotRenderer.setBaseToolTipGenerator(new PlotToolTipGenerator());

    plot.setRenderer(spotRenderer);

}