Friday, March 13, 2009

Flex embedding fonts within Buttons

I was using embedded (ttf) fonts within some Flex labels and they rendered fine; however, when I tried using the same font-family with Flex Buttons, they did not render at all. After some testing, I think I have it figured out,: if your embedded fonts don't render correctly, they may be using default flex font settings that are not supported within the ttf file. I had to make sure that my font-family was using 'fontWeight: normal' to make my own embedded font appear.

Here is an example, notice (in purple) what I added:



@font-face {
src: url("TravelingTypewriter.ttf");
fontFamily: TravelingTypewriter;
advancedAntiAliasing: true;
}

.myStyle {
embedFonts: true;
fontFamily: TravelingTypewriter;
textRolloverColor: red;
fontWeight: normal;
}




Tuesday, January 6, 2009

Comipling Flex components together with your application via command-line

Flex’s “mxmlc” compiler automatically searches sub-folders within your root package directory for source files, you don’t need to specify them on the command line. The reason mxmlc might complain that it does not know where some custom ActionScript classes are is because you may have forgotten to import the custom component files inside the class you use them in!

Tuesday, December 9, 2008

Java classpath - adding libraries and jars

Setting/Using the Java classpath always brings up some trouble, especially when a lot of external libraries or JARs are needed.

Well, here is something to make life easier. It is apparently new with JDK 1.6: the wildcard character. It adds to the classpath ALL JARs, classfiles, zipped libraries etc. inside a particular directory.

To compile a Java file that needs a long list of JARs or external classes, try:
> javac -cp "path-to-library-folder/*" MyJavaClass.java
  • NOTE: Don't forget the quotes

To run a Java class that needs a long list of JARs or external classes, try something like:
> java -cp ".;path-to-library-folder/*" MyJavaClass
  • NOTE: Don't forget to include the current directory by putting "." in the class-path
  • NOTE: Don't forget the quotes again

Thursday, December 4, 2008

J2EE 1.4 JMS problems using java.sun.com JMS tutorial

Apparently Sun's JMS tutorial has not been updated to work with J2EE 1.4 and thus most of the commands they tell you to do simply do not work. This is because there's been a lot of changes to the names of J2EE commands that you type at the command prompt.


Here are some guidelines:
  • When you download J2EE 1.4, just use their default installation directory. Do not install in a directory that has spaces in its path (ie. "Program Files\..." if you use Windows) as Java has trouble finding directories with spaces in them when you set "classpath" etc.
  • Starting the J2EE server was a problem because my system simply could not find the progam called: "j2ee". In J2EE 1.4, this program has been renamed to "asadmin" 
    • Start J2EE server in version 1.3, type: j2ee
    • Start J2EE server in version 1.4, type: asadmin start-domain
  • Adding a JMS destination queue is also different in J2EE 1.4
    • Add JMS destination queue in version 1.3, type: j2eeadmin -addJmsDestination MyQueue queue
    • Start J2EE server in version 1.4, type: asadmin create-jmsdest -T queue MyQueue
  • To view a list of JMS destinations is different in J2EE 1.4
    • View JMS destination list in version 1.3, type: j2eeadmin -listJmsDestination
    • Start J2EE server in version 1.4, type: asadmin list-jmsdest

Wednesday, December 3, 2008

Perl: Converting between day of year (DOY) dates and normal YYMMDD dates

Perl has limited support for converting between dates, and to convert between dates that include "day of year" values, you will need an external Perl module. 
 
Use the module: Date::Calc
 
 To convert a date like YY/DOY to YY/MM/DD format, try: 
  • Use  Add_Delta_Days function in Date::Calc
  • Extract by: 
 my ($new_year, $new_month, $new_day) = Add_Delta_Days($old_year, 1, 1, $old_doy - 1);
 
          Where: 
$new_year is the year value in YY/MM/DD
$new_month is the month value in YY/MM/DD
$new_day is the day value in YY/MM/DD
$old_year is the year value in YY/DOY
$old_doy is the day of year value in YY/DOY
We set the second and third arguments of Add_Delta_Days to "1" because we want to add the number of days starting from January 1st of the given year 



To convert a date like YY/MM/DD to YY/DOY, try:
  • Use  Day_of_Year function in Date::Calc
  • Calculate the day of the year by:
  my $doy = Day_of_Year($year, $month, $day);
 
 

NOTE: Don't forget to include the Date::Calc package by stating at the top of your file:
use Date::Calc qw(Add_Delta_Days Day_of_Year);
 


For more information, see:

Tuesday, November 25, 2008

Getting around NetBeans 6 GUI builder's dependence on Java 6

NetBeans 6 GUI builder is great, but uses a new type of swing layout called the "GroupLayout" by default. This type of layout is only available in Java 6, and so if you try to run your compiled NetBeans 6 code with an older Java version, you get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/swing/GroupLayout$Group
 
The way to overcome this in NetBeans, is to open up the NetBeans inspector window (lower right when in design mode), right-click on each of your forms and go to properties. Inside the properties window, you will see an option for "Layout generation style". Change this value from "Standard Java 6 code" to "Swing Layout Extensions Library".
 
Recompile, and you will be able to run your app in older Java versions (for example, Java 5).
*Remember to change ALL your forms individually! 

Sunday, November 9, 2008

Screen resolution too low on monitor

I was unable to use the maximum resolution I have on my monitor with Ubuntu. I was limited to only using an 800x600 screen resolution.

Here are my specs:
  • Ubuntu 64bit Hardy
  • Samsung T240 22" monitor
  • NVIDIA Ge Force 9800 GTX
  • Intel Quad Core

I am using the Nvidia native driver + software and installed it onto my system. Get it from here (I can't remember which one, but probably the second):

To fix the resolution problem above, I did the following:
  1. Download and install the native NVIDIA driver software
  2. Close your X-session in order to run the nvidia drivers installation program. Do this by running the command:
    sudo /etc/init.d/gdm stop
  3. Run the NVIDIA drivers installation program by running the command:
    sudo nvidia-installer
  4. After running the driver installation program, your X11 config file that the installer generated could be incorrect (mine was), open up your X11 config file by typing the command:
    sudo vim /etc/X11/xorg.conf
  5. Change the following entries in your xorg.conf file:
    • In the section titled "Monitor", comment out the line defining "modeline" by putting a "#" before it. This line should not be executed.
    • In the sub-section called "Display" within the section called "Screen", change the resolutions listed to "1920" by "1200".
  6. Restart your X server by running the command:
    sudo /etc/init.d/gdm start
Your monitor should now start with the higher resolution. Try restarting your computer if you don't see a difference yet or all features are not yet working. Your final X11 config file could look the following:


# xorg.conf (X.Org X Window System server configuration file)
#
# This file was generated by failsafeDexconf, using
# values from the debconf database and some overrides to use vesa mode.
#
# You should use dexconf or another such tool for creating a "real" xorg.conf
# For example:
# sudo dpkg-reconfigure -phigh xserver-xorg
Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection

Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
EndSection

Section "Device"
Identifier "Configured Video Device"
Boardname "vesa"
Busid "PCI:3:0:0"
Driver "vesa"
Screen 0
EndSection

Section "Monitor"
Identifier "Configured Monitor"
Vendorname "Plug 'n' Play"
Modelname "Plug 'n' Play"
#modeline "640x480@60" 25.2 640 656 752 800 480 490 492 525 -vsync -hsync
Gamma 1.0
EndSection

Section "Screen"
Identifier "Default Screen"
Device "Configured Video Device"
Monitor "Configured Monitor"
Defaultdepth 24
SubSection "Display"
Depth 24
Virtual 1920 1200
Modes "1920x1200@60"
EndSubSection
EndSection

Section "ServerLayout"
Identifier "Default Layout"
screen 0 "Default Screen" 0 0
EndSection
Section "Module"
Load "glx"
Load "GLcore"
Load "v4l"