3434import com .jme3 .asset .AssetNotFoundException ;
3535import com .jme3 .system .AppSettings ;
3636import com .jme3 .system .JmeSystem ;
37+ import com .jme3 .system .Platform ;
3738
3839import java .awt .*;
3940import java .awt .event .*;
4243import java .net .MalformedURLException ;
4344import java .net .URL ;
4445import java .text .MessageFormat ;
45- import java .util .ArrayList ;
4646import java .util .Arrays ;
4747import java .util .Comparator ;
4848import java .util .LinkedHashSet ;
@@ -125,11 +125,13 @@ public interface SelectionListener {
125125 private JCheckBox vsyncBox = null ;
126126 private JCheckBox gammaBox = null ;
127127 private JCheckBox fullscreenBox = null ;
128+ private JCheckBox x11PlatformPreferredBox = null ;
128129 private JComboBox <String > displayResCombo = null ;
129130 private JComboBox <String > colorDepthCombo = null ;
130131 private JComboBox <String > displayFreqCombo = null ;
131132 private JComboBox <String > antialiasCombo = null ;
132133 private JComboBox <String > rendererCombo = null ;
134+ private JComboBox <DisplayScaleModeOption > displayScaleModeCombo = null ;
133135 private JLabel icon = null ;
134136 private int selection = 0 ;
135137 private SelectionListener selectionListener = null ;
@@ -466,6 +468,8 @@ public void keyPressed(KeyEvent e) {
466468 antialiasCombo .addKeyListener (aListener );
467469 rendererCombo = setUpRendererChooser ();
468470 rendererCombo .addKeyListener (aListener );
471+ displayScaleModeCombo = setUpDisplayScaleModeChooser ();
472+ displayScaleModeCombo .addKeyListener (aListener );
469473 fullscreenBox = new JCheckBox (resourceBundle .getString ("checkbox.fullscreen" ));
470474 fullscreenBox .setSelected (source .isFullscreen ());
471475 fullscreenBox .addActionListener (new ActionListener () {
@@ -481,6 +485,10 @@ public void actionPerformed(ActionEvent e) {
481485 gammaBox = new JCheckBox (resourceBundle .getString ("checkbox.gamma" ));
482486 gammaBox .setSelected (source .isGammaCorrection ());
483487
488+ x11PlatformPreferredBox = new JCheckBox (resourceBundle .getString ("checkbox.x11PlatformPreferred" ));
489+ x11PlatformPreferredBox .setSelected (source .isX11PlatformPreferred ());
490+ boolean linux = JmeSystem .getPlatform ().getOs () == Platform .Os .Linux ;
491+
484492 GridBagConstraints gbc = new GridBagConstraints ();
485493 gbc .weightx = 0.5 ;
486494 gbc .gridx = 0 ;
@@ -562,10 +570,34 @@ public void actionPerformed(ActionEvent e) {
562570 gbc = new GridBagConstraints ();
563571 gbc .gridx = 1 ;
564572 gbc .gridy = 4 ;
565- gbc .gridwidth = 3 ;
573+ gbc .gridwidth = linux ? 1 : 3 ;
566574 gbc .anchor = GridBagConstraints .WEST ;
567575 mainPanel .add (rendererCombo , gbc );
568576
577+ if (linux ) {
578+ gbc = new GridBagConstraints ();
579+ gbc .insets = new Insets (4 , 16 , 4 , 4 );
580+ gbc .gridx = 2 ;
581+ gbc .gridy = 4 ;
582+ gbc .gridwidth = 2 ;
583+ gbc .anchor = GridBagConstraints .WEST ;
584+ mainPanel .add (x11PlatformPreferredBox , gbc );
585+ }
586+
587+ gbc = new GridBagConstraints ();
588+ gbc .insets = new Insets (4 , 4 , 4 , 4 );
589+ gbc .gridx = 0 ;
590+ gbc .gridy = 5 ;
591+ gbc .anchor = GridBagConstraints .EAST ;
592+ gbc .weightx = 0.5 ;
593+ mainPanel .add (new JLabel (resourceBundle .getString ("label.displayScaleMode" )), gbc );
594+ gbc = new GridBagConstraints ();
595+ gbc .gridx = 1 ;
596+ gbc .gridy = 5 ;
597+ gbc .gridwidth = 3 ;
598+ gbc .anchor = GridBagConstraints .WEST ;
599+ mainPanel .add (displayScaleModeCombo , gbc );
600+
569601 // Set the button action listeners. Cancel disposes without saving, OK
570602 // saves.
571603 ok .addActionListener (new ActionListener () {
@@ -600,14 +632,14 @@ public void actionPerformed(ActionEvent e) {
600632 gbc = new GridBagConstraints ();
601633 gbc .gridx = 0 ;
602634 gbc .gridwidth = 2 ;
603- gbc .gridy = 5 ;
635+ gbc .gridy = 6 ;
604636 gbc .anchor = GridBagConstraints .EAST ;
605637 mainPanel .add (ok , gbc );
606638 gbc = new GridBagConstraints ();
607639 gbc .insets = new Insets (4 , 16 , 4 , 4 );
608640 gbc .gridx = 2 ;
609641 gbc .gridwidth = 2 ;
610- gbc .gridy = 5 ;
642+ gbc .gridy = 6 ;
611643 gbc .anchor = GridBagConstraints .WEST ;
612644 mainPanel .add (cancel , gbc );
613645
@@ -739,6 +771,12 @@ private boolean verifyAndSaveCurrentSelection() {
739771 source .setFullscreen (fullscreen );
740772 source .setVSync (vsync );
741773 source .setGammaCorrection (gamma );
774+ source .setX11PlatformPreferred (x11PlatformPreferredBox .isSelected ());
775+ DisplayScaleModeOption displayScaleMode
776+ = (DisplayScaleModeOption ) displayScaleModeCombo .getSelectedItem ();
777+ if (displayScaleMode != null ) {
778+ source .setDisplayScaleMode (displayScaleMode .value );
779+ }
742780 source .setRenderer (renderer );
743781 source .setSamples (multisample );
744782
@@ -804,6 +842,55 @@ private JComboBox<String> setUpRendererChooser() {
804842 return rendererBox ;
805843 }
806844
845+ private JComboBox <DisplayScaleModeOption > setUpDisplayScaleModeChooser () {
846+ JComboBox <DisplayScaleModeOption > scaleModeBox = new JComboBox <>();
847+ float currentMode = source .getDisplayScaleMode ();
848+ float [] standardModes = {
849+ AppSettings .DISPLAY_SCALE_DISABLED ,
850+ AppSettings .DISPLAY_SCALE_NATIVE_PIXELS ,
851+ AppSettings .DISPLAY_SCALE_DPI_AWARE ,
852+ 2f ,
853+ 3f ,
854+ 4f ,
855+ 5f ,
856+ 6f ,
857+ 7f ,
858+ 8f
859+ };
860+
861+ boolean currentModeAdded = false ;
862+ for (float mode : standardModes ) {
863+ DisplayScaleModeOption option = createDisplayScaleModeOption (mode );
864+ scaleModeBox .addItem (option );
865+ if (Float .compare (mode , currentMode ) == 0 ) {
866+ scaleModeBox .setSelectedItem (option );
867+ currentModeAdded = true ;
868+ }
869+ }
870+
871+ if (!currentModeAdded ) {
872+ DisplayScaleModeOption option = createDisplayScaleModeOption (currentMode );
873+ scaleModeBox .addItem (option );
874+ scaleModeBox .setSelectedItem (option );
875+ }
876+
877+ return scaleModeBox ;
878+ }
879+
880+ private DisplayScaleModeOption createDisplayScaleModeOption (float mode ) {
881+ String label ;
882+ if (mode == AppSettings .DISPLAY_SCALE_DISABLED ) {
883+ label = resourceBundle .getString ("displayScaleMode.disabled" );
884+ } else if (mode == AppSettings .DISPLAY_SCALE_NATIVE_PIXELS ) {
885+ label = resourceBundle .getString ("displayScaleMode.nativePixels" );
886+ } else if (mode == AppSettings .DISPLAY_SCALE_DPI_AWARE ) {
887+ label = resourceBundle .getString ("displayScaleMode.dpiAware" );
888+ } else {
889+ label = MessageFormat .format (resourceBundle .getString ("displayScaleMode.supersampling" ), mode );
890+ }
891+ return new DisplayScaleModeOption (label , mode );
892+ }
893+
807894 /**
808895 * <code>updateDisplayChoices</code> updates the available color depth and
809896 * display frequency options to match the currently selected resolution.
@@ -1069,4 +1156,19 @@ public int compare(DisplayMode a, DisplayMode b) {
10691156 return 0 ;
10701157 }
10711158 }
1159+
1160+ private static final class DisplayScaleModeOption {
1161+ private final String label ;
1162+ private final float value ;
1163+
1164+ private DisplayScaleModeOption (String label , float value ) {
1165+ this .label = label ;
1166+ this .value = value ;
1167+ }
1168+
1169+ @ Override
1170+ public String toString () {
1171+ return label ;
1172+ }
1173+ }
10721174}
0 commit comments