package bluej.editor.stride;
import java.util.List;
import bluej.utility.javafx.FXConsumer;
import bluej.utility.javafx.JavaFXUtil;
import javafx.beans.binding.ObjectExpression;
import javafx.beans.binding.StringExpression;
import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.value.ObservableStringValue;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.Tab;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import threadchecker.OnThread;
import threadchecker.Tag;
| There's not really a good name for this, but essentially it is a subclass of Tab
| which adds some methods which FXTabbedEditor needs to call on its contained tabs.
|
| The three subclasses of this class (at the moment) are FrameEditorTab for Stride classes,
| MoeFXTab for Java classes, and WebTab for web browser (for documentation).
|
@OnThread(Tag.FXPlatform)
abstract class FXTab
extends Tab{
private final boolean showCatalogue;
public FXTab(boolean showCatalogue)
{
this.showCatalogue = showCatalogue;
}
| A helper method used by subclasses to create an ImageView for a given
| observable image expression (which may have a null Image in it)
| @param imageExpression The image expression to watch for changes
| @param maxSize The maximum width and height of the image
| @param scaleUp If true, scale the image up to the max image width/height (while preserving aspect ratio).
| If false and the image is smaller than max size, do not scale it up.
| @return An imageView which displays the latest image.
|
@OnThread(Tag.FX)
protected static ImageView makeClassGraphicIcon(ObjectExpression<Image> imageExpression, int maxSize, boolean scaleUp)
{
ImageView imageView = new ImageView();
FXConsumer<Image> imageChanged = image -> {
if (image == null)
{
imageView.setFitWidth(0);
imageView.setFitHeight(0);
}
else if (scaleUp)
{
imageView.setFitHeight(maxSize);
imageView.setFitWidth(maxSize);
}
else
{
imageView.setFitHeight(Math.min(image.getHeight(), maxSize));
imageView.setFitWidth(Math.min(image.getWidth(), maxSize));
}
imageView.setImage(image);
};
imageView.setPreserveRatio(true);
imageChanged.accept(imageExpression.get());
JavaFXUtil.addChangeListener(imageExpression, imageChanged);
return imageView;
}
| Initialises any FX items which need to be done on the FX thread.
|
@OnThread(Tag.FXPlatform)
abstract void initialiseFX();
| When this tab gets shown as the selected tab, focus an appropriate item
| within the tab.
|
abstract void focusWhenShown();
| When the tab gets selected, this method is called to find out the menus whic
| should be shown in the menubar (which is per-window, and thus shared between all
| tabs)
| @return The list of menus to use for the top menubar.
|
abstract List
top,
use,
map,
abstract class FXTab
. FXTab
. makeClassGraphicIcon
. initialiseFX
. focusWhenShown
. getMenus
. setParent
. getParent
. getWebAddress
. windowTitleProperty
. notifySelected
. notifyUnselected
. shouldShowCatalogue
. isTutorial
117 neLoCode
+ 30 LoComm