1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
1378 private float lmVal = -1f,rmVal = -1f, tmVal = -1f, bmVal = -1f;
1379 // storage for margins as objects mapped into orientation for display
1380 private Float lmObj,rmObj,tmObj,bmObj;
1381
1382 public MarginsPanel() {
1383 super();
1384
1385 GridBagLayout gridbag = new GridBagLayout();
1386 GridBagConstraints c = new GridBagConstraints();
1387 c.fill = GridBagConstraints.HORIZONTAL;
1388 c.weightx = 1.0;
1389 c.weighty = 0.0;
1390 c.insets = compInsets;
1391
1392 setLayout(gridbag);
1393 setBorder(BorderFactory.createTitledBorder(strTitle));
1394
1395 String unitsKey = "label.millimetres";
1396 String defaultCountry = Locale.getDefault().getCountry();
1397 if (defaultCountry != null &&
1398 (defaultCountry.equals("") ||
1399 defaultCountry.equals(Locale.US.getCountry()) ||
1400 defaultCountry.equals(Locale.CANADA.getCountry()))) {
1401 unitsKey = "label.inches";
1402 units = MediaPrintableArea.INCH;
1403 }
1404 String unitsMsg = getMsg(unitsKey);
1405
1406 DecimalFormat format;
1407 if (units == MediaPrintableArea.MM) {
1408 format = new DecimalFormat("###.##");
1409 format.setMaximumIntegerDigits(3);
1410 } else {
1411 format = new DecimalFormat("##.##");
1412 format.setMaximumIntegerDigits(2);
1413 }
1414
1415 format.setMinimumFractionDigits(1);
1416 format.setMaximumFractionDigits(2);
1417 format.setMinimumIntegerDigits(1);
1418 format.setParseIntegerOnly(false);
|
1 /*
2 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
1378 private float lmVal = -1f,rmVal = -1f, tmVal = -1f, bmVal = -1f;
1379 // storage for margins as objects mapped into orientation for display
1380 private Float lmObj,rmObj,tmObj,bmObj;
1381
1382 public MarginsPanel() {
1383 super();
1384
1385 GridBagLayout gridbag = new GridBagLayout();
1386 GridBagConstraints c = new GridBagConstraints();
1387 c.fill = GridBagConstraints.HORIZONTAL;
1388 c.weightx = 1.0;
1389 c.weighty = 0.0;
1390 c.insets = compInsets;
1391
1392 setLayout(gridbag);
1393 setBorder(BorderFactory.createTitledBorder(strTitle));
1394
1395 String unitsKey = "label.millimetres";
1396 String defaultCountry = Locale.getDefault().getCountry();
1397 if (defaultCountry != null &&
1398 (defaultCountry.isEmpty() ||
1399 defaultCountry.equals(Locale.US.getCountry()) ||
1400 defaultCountry.equals(Locale.CANADA.getCountry()))) {
1401 unitsKey = "label.inches";
1402 units = MediaPrintableArea.INCH;
1403 }
1404 String unitsMsg = getMsg(unitsKey);
1405
1406 DecimalFormat format;
1407 if (units == MediaPrintableArea.MM) {
1408 format = new DecimalFormat("###.##");
1409 format.setMaximumIntegerDigits(3);
1410 } else {
1411 format = new DecimalFormat("##.##");
1412 format.setMaximumIntegerDigits(2);
1413 }
1414
1415 format.setMinimumFractionDigits(1);
1416 format.setMaximumFractionDigits(2);
1417 format.setMinimumIntegerDigits(1);
1418 format.setParseIntegerOnly(false);
|