Closed tiwawan closed 9 years ago
備考:
*
* Saves one frame as a PDF with a size larger
* than the screen. When PDF is used as the renderer
* (the third parameter of size) the display window
* does not open. The file is saved to the sketch folder.
*/
I ran example of PDF library named "LargePage", and I had difficulty in finding the generated pdf file. The comment in LargePage says "The file is saved to the sketch folder," but I think this is unfriendly because we usually open example from "File->Examples..." so we don't care about where sketch folder is. Fortunately, we can open sketch folder by "Sketch->Show Sketch Folder." How about adding a comment about this?
iso-8859
...
public Font getFont(String attribute) {
return theme.getFont(attribute);
}
...
さらに、
...
public void setupGUI() {
try {
// First load the default theme data for the whole PDE.
theme = new Settings(Base.getContentFile("lib/theme.txt"));
...
これが核心に近い? 次はBaseクラスとtheme.txtを読む
static protected File processingRoot;
/**
* Get reference to a file adjacent to the executable on Windows and Linux,
* or inside Contents/Resources/Java on Mac OS X.
*/
static public File getContentFile(String name) {
if (processingRoot == null) {
// Get the path to the .jar file that contains Base.class
String path = Base.class.getProtectionDomain().getCodeSource().getLocation().getPath();
// Path may have URL encoding, so remove it
String decodedPath = PApplet.urlDecode(path);
if (decodedPath.contains("/app/bin")) { // This means we're in Eclipse
if (Base.isMacOS()) {
processingRoot =
new File(path, "../../build/macosx/work/Processing.app/Contents/Java");
} else if (Base.isWindows()) {
processingRoot = new File(path, "../../build/windows/work");
} else if (Base.isLinux()) {
processingRoot = new File(path, "../../build/linux/work");
}
} else {
// The .jar file will be in the lib folder
File jarFolder = new File(decodedPath).getParentFile();
if (jarFolder.getName().equals("lib")) {
// The main Processing installation directory.
// This works for Windows, Linux, and Apple's Java 6 on OS X.
processingRoot = jarFolder.getParentFile();
} else if (Base.isMacOS()) {
// This works for Java 8 on OS X. We don't have things inside a 'lib'
// folder on OS X. Adding it caused more problems than it was worth.
processingRoot = jarFolder;
}
if (processingRoot == null || !processingRoot.exists()) {
// Try working directory instead (user.dir, different from user.home)
System.err.println("Could not find lib folder via " +
jarFolder.getAbsolutePath() +
", switching to user.dir");
processingRoot = new File(System.getProperty("user.dir"));
}
}
}
return new File(processingRoot, name);
}
Fileを返す(設定をデコードしている訳ではない)。設定ファイルのフォルダの環境ごとの違いを吸収するのが主な目的のメソッドだったようだ。
editor.gutter.text.font = processing.mono,plain,11
これか? ビルドした時点ですでにメニューバーが日本語になっていたが、それをどこでやっているのか探る。
static private void createAndShowGUI(String[] args) {
...
// Load the languages
Language.init();
// run static initialization that grabs all the prefs
Preferences.init();
Language, Preferencesが関係していそうだ。
なんかすごい。コードの海にディープダイビングしてる!
static public void main(final String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
createAndShowGUI(args);
} catch (Throwable t) {
showBadnessTrace("It was not meant to be",
"A serious problem happened during startup. Please report:\n" +
"http://github.com/processing/processing/issues/new", t, true);
}
}
});
}
Baseクラス内にあるようだ。 直前のコメントに貼ったcreateAndShowGUI()は約2番めに呼ばれる関数であることがわかった。
/** Singleton constructor */
static public Language init() {
if (instance == null) {
synchronized (Language.class) {
if (instance == null) {
instance = new Language();
}
}
}
return instance;
}
Singleton constructorとは↓のことか?OSSでデサインパターンの知識もつけて圧倒的成長:muscle::muscle::muscle: https://ja.wikipedia.org/wiki/Singleton_%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3
真のコンストラクタは以下
Base..java l51
private Language() {
String systemLanguage = Locale.getDefault().getLanguage();
language = loadLanguage();
boolean writePrefs = false;
if (language == null) {
language = systemLanguage;
writePrefs = true;
}
// Set available languages
languages = new HashMap<String, String>();
for (String code : listSupported()) {
Locale locale = Locale.forLanguageTag(code);
languages.put(code, locale.getDisplayLanguage(locale));
}
// Set default language
if (!languages.containsKey(language)) {
language = "en";
writePrefs = true;
}
if (writePrefs) {
saveLanguage(language);
}
// Get bundle with translations (processing.app.language.PDE)
//bundle = ResourceBundle.getBundle(Language.FILE, new Locale(this.language), new UTF8Control());
try {
bundle = new LanguageBundle(language);
} catch (IOException e) {
e.printStackTrace();
}
}
Locale.getDefault().getLanguage()が、自動で言語を選択するためのコードであるようだ。これがあったから自分の環境ではメニューバーが日本語になっていたと予想。
Locale オブジェクトは、地理的、政治的、または文化的に特定の地域を表しています。ある操作で Locale を必要とするタスクがある場合、その操作をロケールに依存する操作といいます。 この場合、情報は Locale によりユーザーに合わせて調整されます。たとえば、数値を表示するのは、ロケールに依存する操作です。 この数値は、ユーザーの国や地域、文化の習慣や規則に従ってフォーマットする必要があります。
Locale オブジェクトを作成するには、このクラスのコンストラクタを使用します。
Locale(String language) Locale(String language, String country) Locale(String language, String country, String variant)
言語の引数は、有効な ISO 言語コードです。これらのコードは、ISO-639 で定義される 2 桁の小文字です。
static Locale getDefault() Java Virtual Machine のこのインスタンスに対して、デフォルトロケールの現在の値を取得します。
static protected final String PREF_FILE = "language.txt";
static protected final File prefFile = Base.getSettingsFile(PREF_FILE);
...
/** Read the saved language */
static private String loadLanguage() {
try {
if (prefFile.exists()) {
String language = PApplet.loadStrings(prefFile)[0];
language = language.trim().toLowerCase();
if (language.trim().length() != 0) {
return language;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* Save the language directly to a settings file. This is 'save' and not
* 'set' because a language change requires a restart of Processing.
*/
static public void saveLanguage(String language) {
try {
Base.saveFile(language, prefFile);
} catch (Exception e) {
e.printStackTrace();
}
Base.getPlatform().saveLanguage(language);
}
language.txtから設定をとっているようだ
public class Preferences {
// had to rename the defaults file because people were editing it
static final String DEFAULTS_FILE = "defaults.txt"; //$NON-NLS-1$
static final String PREFS_FILE = "preferences.txt"; //$NON-NLS-1$
static HashMap<String, String> defaults;
static HashMap<String, String> table = new HashMap<String, String>();
static File preferencesFile;
static public void init() {
// start by loading the defaults, in case something
// important was deleted from the user prefs
try {
// Name changed for 2.1b2 to avoid problems with users modifying or
// replacing the file after doing a search for "preferences.txt".
load(Base.getLibStream(DEFAULTS_FILE));
} catch (Exception e) {
Base.showError(null, "Could not read default settings.\n" +
"You'll need to reinstall Processing.", e);
}
...
static public void load(InputStream input) throws IOException {
HashMap<String, String> platformSpecific = new HashMap<>();
String[] lines = PApplet.loadStrings(input); // Reads as UTF-8
for (String line : lines) {
if ((line.length() == 0) ||
(line.charAt(0) == '#')) continue;
// this won't properly handle = signs being in the text
int equals = line.indexOf('=');
if (equals != -1) {
String key = line.substring(0, equals).trim();
String value = line.substring(equals + 1).trim();
if (!isPlatformSpecific(key, value, platformSpecific)) {
table.put(key, value);
}
}
}
// Now override the keys with any platform-specific defaults we've found.
for (String key : platformSpecific.keySet()) {
table.put(key, platformSpecific.get(key));
}
}
preferences.txtの中身を=の左右で切ったペアをtableの中に放り込んでいるらしい
buttons.hide.image=false
chooser.files.native=false
console.auto_clear=true
console.font.size=12
console.length=500
console.lines=4
contribution.backup.on_install=true
contribution.backup.on_remove=true
editor.caret.blink=true
editor.caret.block=false
editor.divider.size=0
editor.font.family=Takaoゴシック
editor.font.size=12
editor.indent=true
editor.input_method_support=true
editor.keys.alternative_cut_copy_paste=true
editor.keys.home_and_end_travel_far=false
editor.keys.home_and_end_travel_smart=true
editor.keys.shift_backspace_is_delete=false
editor.laf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel
editor.smooth=true
editor.tabs.expand=true
editor.tabs.size=2
editor.token.comment1.style=#666666,plain
editor.token.comment2.style=#666666,plain
editor.token.function1.style=#006699,plain
editor.token.function2.style=#006699,plain
editor.token.function3.style=#669900,plain
editor.token.function4.style=#006699,bold
editor.token.invalid.style=#666666,bold
editor.token.keyword1.style=#33997e,plain
editor.token.keyword2.style=#33997e,plain
editor.token.keyword3.style=#669900,plain
editor.token.keyword4.style=#d94a7a,plain
editor.token.keyword5.style=#e2661a,plain
editor.token.keyword6.style=#33997e,plain
editor.token.label.style=#666666,bold
editor.token.literal1.style=#7D4793,plain
editor.token.literal2.style=#718a62,plain
editor.token.operator.style=#006699,plain
editor.untitled.prefix=sketch_
editor.untitled.suffix=yyMMdd
editor.watcher=true
editor.window.height.default=600
editor.window.height.min=500
editor.window.width.default=500
editor.window.width.min=400
examples.processing.mode.java.JavaMode.visible=Examples:Examples/Demos:Examples/Topics/Create Shapes:Examples/Topics/Cellular Automata:Examples/Topics/Drawing:Examples/Topics:Examples/Books:Examples/Topics/Textures:Examples/Topics/Simulate
export.application.embed_java=true
export.application.fullscreen=false
export.application.stop=true
export.delete_target_folder=true
instance_server.key=0.818758459940237
instance_server.port=41774
last.sketch.count=0
last.sketch.mode=processing.mode.java.JavaMode
last.sketch.restore=true
launcher=xdg-open
mode.last=processing.mode.java.JavaMode
pdex.autoSave.autoSaveByDefault=true
pdex.autoSave.autoSaveEnabled=false
pdex.autoSave.promptDisplay=true
pdex.autoSaveInterval=5
pdex.completion=false
pdex.completion.trigger=false
pdex.dbgOutput=false
pdex.errorCheckEnabled=true
pdex.importSuggestEnabled=true
pdex.warningsEnabled=true
pdex.writeErrorLogs=false
platform.auto_file_type_associations=true
preproc.color_datatype=true
preproc.enhanced_casting=true
preproc.output_parse_tree=false
preproc.save_build_files=false
preproc.substitute_floats=true
preproc.substitute_unicode=true
preproc.web_colors=true
proxy.host=
proxy.http.host=
proxy.http.port=
proxy.https.host=
proxy.https.port=
proxy.port=
proxy.socks.host=
proxy.socks.port=
recent.count=10
run.display=1
run.options=
run.options.memory=false
run.options.memory.initial=64
run.options.memory.maximum=256
run.present.bgcolor=#666666
run.present.stop.color=#cccccc
run.window.bgcolor=#DFDFDF
sketchbook.path=/home/tiwawan/sketchbook
sketchbook.path.three=/home/tiwawan/sketchbook
toolbar.hide.image=false
update.check=true
update.id=5274890482117385628
update.last=1436666801566
input_method_supportが設定ウインドウの「複雑なテキスト入力を有効にする」に相当している?要検証
/**
* Inline Input Method Support for Japanese.
*/
public InputMethodRequests getInputMethodRequests() {
if (Preferences.getBoolean("editor.input_method_support")) {
if (inputMethodSupport == null) {
inputMethodSupport = new InputMethodSupport(this);
}
return inputMethodSupport;
}
return null;
}
$ grep -r getInputMethodRequests --include='*.java'
app/src/processing/app/syntax/JEditTextArea.java: public InputMethodRequests getInputMethodRequests() {
tiwawan@tiwawan-X200MA:~/Documents/processing$ grep -r input_method_support --include='*.java'
app/src/processing/app/syntax/JEditTextArea.java: if (Preferences.getBoolean("editor.input_method_support")) {
app/src/processing/app/ui/PreferencesFrame.java: Preferences.setBoolean("editor.input_method_support", inputMethodBox.isSelected()); //$NON-NLS-1$
app/src/processing/app/ui/PreferencesFrame.java: inputMethodBox.setSelected(Preferences.getBoolean("editor.input_method_support")); //$NON-NLS-1$
getInputMethodRequests()が定義されただけでどこでも呼ばれていない???
public InputMethodRequests getInputMethodRequests() {
if (!Preferences.getBoolean("editor.input_method_support")) {
if (inputMethodSupport == null) {
inputMethodSupport = new InputMethodSupport(this);
}
return inputMethodSupport;
}
return null;
}
真偽判定を逆転させて(!Preferences.getBoolean("editor.input_method_support"))再起動させると、逆転させる前と逆の(つまり期待通りの)結果が得られた。
再起動の問題かもしれないと考えたが、逆転させないと再起動させても動作が期待と逆のままだった。
https://github.com/clear-code/sezemi-2015/issues/63#fullscreen* 作業:getInputMethodRequests()の中にバグを入れて呼び出し元を探る。
public InputMethodRequests getInputMethodRequests() {
int a=1/0;
if (Preferences.getBoolean("editor.input_method_support")) {
if (inputMethodSupport == null) {
inputMethodSupport = new InputMethodSupport(this);
}
return inputMethodSupport;
}
return null;
}
エラーメッセージ
Processing外のInputMethodAdapterとかいうところから呼びだされている。
getInputMethodRequests()はorg.gjt.sp.jedit.textarea.TextAreaからオーバーロードしたメソッドだったらしい。
たぶん内部的に使われているのだろう:pensive:
お疲れ様でしたにゃん :cat:
https://github.com/processing/processing
作業ログは、参加者が、このイベントを通して得るものをより増やすために重要になります。なぜなら作業ログがメンターからのフィードバックをより充実させるからです。
作業ログを元にメンターと「ふりかえり」をするタイミングがあります。「ふりかえり」では次のことをします。
メンターは次のようなフィードバックをします。これは、参加者とは違う視点から参加者の行動を観察することおよびメンターの経験があるからできることです。(「ふりかえり」の前にこんなフィードバックをよろしくお願いします!とお願いすると効果が高まるので実践してみましょう。)
このように、参加者の作業をメンター視点で一緒に整理し、参加者の今後の行動に活かす活動がここでいう「ふりかえり」です。そのため、「参加者にとって」ログに残すべきかどうか、という視点ではなく、「とりあえずログに残す」という視点でログを残してください。これは、参加者が重要だと判断しなくてもメンターの視点から見たら大事なこともあるからです。
ログに残すときは次のようなときです。
ログに残すことは次のことです。「備考」以外は作業の邪魔にならないように一言でよいです。備考は作業に役立つので必要な分だけ書いてください。
ログはコメントとして追記していってください。テンプレートは次の通りです。
例1(備考なし):
例2:
必要なファイルが足りないのかなぁ。