Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Ports/JavaSE/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ dist.dir=dist
dist.jar=${dist.dir}/JavaSE.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
# The com/codename1/testing/junit package depends on org.junit.jupiter
# (only on the Maven build's classpath as a "provided" dep). The Ant
# build here does not link JUnit in, so skip those sources -- they are
# unused by the simulator integration screenshot tests that drive this
# build, and the user-facing codenameone-javase jar is the Maven one.
excludes=com/codename1/testing/junit/**
file.reference.Filters.jar=../../../cn1-binaries/javase/Filters.jar
file.reference.jcef.jar=../../../cn1-binaries/javase/jcef.jar
file.reference.jmf-2.1.1e.jar=../../../cn1-binaries/javase/jmf-2.1.1e.jar
Expand Down
58 changes: 58 additions & 0 deletions Ports/JavaSE/src/com/codename1/impl/javase/JavaSEPort.java
Original file line number Diff line number Diff line change
Expand Up @@ -3154,6 +3154,64 @@ private void setPortrait(boolean portraitValue) {
}
}

@Override
public boolean isPortrait() {
// When setSimulatorPortrait has been called explicitly (e.g. by the
// @Orientation JUnit annotation), honor that flag rather than the
// canvas-derived inference. The canvas inherits the host window's
// dimensions, which in unit-test JVMs almost always read as
// landscape regardless of what the test asked for.
if (simulatorPortraitExplicit) {
return portrait;
}
return super.isPortrait();
}

/**
* Programmatically flips the simulator between portrait and landscape
* without persisting the choice to user preferences. The menu's Rotate
* action goes through the private {@link #setPortrait(boolean)} helper
* (which does persist, since it is driven by an explicit user click);
* this entry point is meant for runtime / test callers that want the
* orientation state to last only for the current JVM — in
* particular the {@code @Orientation} JUnit annotation.
*
* <p>Sets an explicit-override flag so that {@link #isPortrait()} returns
* this value instead of inferring orientation from canvas dimensions.
* In tests the canvas inherits the host frame's size and the inference
* would otherwise read "landscape" on any wide screen.
*
* @param portraitValue true for portrait, false for landscape
*/
public void setSimulatorPortrait(boolean portraitValue) {
simulatorPortraitExplicit = true;
if (portrait != portraitValue) {
portrait = portraitValue;
updateFrameUI();
}
}

private boolean simulatorPortraitExplicit = false;

/**
* Sets the simulator's accessibility text-scale multiplier. Does not
* persist the value to user preferences &mdash; the Simulate &gt;
* Larger Text menu remains the only restart-stable source of truth.
* Does not refresh the active theme either; the caller decides when
* to redraw (the {@code @LargerText} JUnit annotation, for instance,
* batches several config changes and then issues one refresh).
*
* <p>A value of {@code 1.0f} restores the default size; values like
* {@code 1.3f}, {@code 1.6f}, {@code 2.0f} mirror the menu's
* "AX2 / AX3 / AX5" presets.
*
* @param scale text-scale multiplier; {@code 1.0f} for default
*/
public void setSimulatorLargerTextScale(float scale) {
largerTextScale = scale;
largerTextEnabled = scale > 1.0f + 0.001f;
}


private void updateFrameUI() {
if (instance.appFrame != null) {
Expand Down
Loading
Loading