Sunday 29 July 2007

Pro-life?

I just can't understand how you can be Pro-life and debate that life is sacred and all. Then go home and just eat a piece of meat and don't think about how you just choose to kill a living being. A living being, very well capable of more "living" than a foetus.

All lives are not equal, that's just the way it is. We don't value strangers as much as friends. We'd rather see the entire Nazi party hanged in 1933 than to let them live and cause the killing of millions of innocents. Not considering everyone and everything equal is not a sin, it's natural, and human. Do the quiz below (the parents agree in the case of foetus abortion below, so the choice is entirely yours, which is more sinful?), don't tell me that you have a hard time deciding on which lives to spare. If you do, you are the one who is having a problem with your ethics, not me.

Note:
I should have included, a man and a man as number six, but I was busy trying to draw something that vaguely resembled the text. I am not an artist in any way.

Monday 23 July 2007

Panorama of the view from the "Math tower"

The mathematics department resides in the clock tower at KTH. Therefore it's is called the "Math tower" by the students. You have access to a balcony just above the clock and I have been planning on taking a panorama from there. The outcome was not perfect, there are some ugly seams. But they are not that bad. I want a sunny clear day, perhaps in the winter. That might be perfect for a view of Stockholm.

Link to a the larger version (even though you can spot the seams easier).

Link to the larger version.

Friday 20 July 2007

Panorama of Rynningeviken

Yesterday I took myself time to process one of the panoramas from my trip to Örebro and Lindesberg back in early June. I have gotten a lot better but I still have a lot to learn. I am not at all pleased with the look of a 220 degree panorama. I really should read up on more general info on panoramas before processing the other two panoramas I have from that trip. The outcome is linked below.


(As usual Google won't allow me to upload obscenely large images, so here is a link to the real deal)

Thursday 12 July 2007

SvD on science or when journalism goes bad

Today, three scientist posted an article in Göteborgs-Posten, a fairly large Swedish paper where they claim that a rather new Swedish anti-hangover pill Revigör has no effects on hangovers what so ever. I will translate some parts of the article, trying to shorten it down.

"Worried about a hangover? No problem, now Swedish doctors have developed an effective medicine that makes you feel well the day after! This is the message brought to you by Revigör advertisement."

"Revigör comes at a price of 50 SEK and each box contains three pills which ingredients are vitamins, sugar, salt and coffein. But there are no proofs of living up to it's claims."

These are the main things the scientists point out.

First, to have been developed by a Doctor Haglund, yet this person has not published any scientific articles or papers regarding the effect of alcohol. Although Revigör claims that he "has dedicated his life" to the effects of alcohol.

Secondly, Revigör claims to be "a result of Swedish research" and "to have been tested and shown good results in a double-blind placecontrolled study done by doctors from Karolinska Institutet and Uppsala University". Yet, no such study has ever been published. The scientists contacted the owner of the company that produces Revigör and asked for the study. He replied that it was a company secret and that they only share it with business partners. All that are familiar with how science in all forms in conducted, know that you can never make any claims related to an unpublished study. You can't just say "I have proof, but I won't show it". The scientists then point out that it's of economic interest to the company whether or not the study is correct and that one therefore could doubt their motives on keeping it secret.

The scientists the proceed to explaining how it is possible to sell a product that has scientific claims of medical effect and no proofs, in Sweden. This is due to the company labeling their product as vitamins and nutritions instead of medicine. Thus bypassing the Swedish laws and regulations on medicinal products.

Lastly the scientists implies that a people taking medication against hang-overs might be more likely to drink more. They supply no proof of this, but argues that this is not something of good. Especially since Revigör can be sold to people already drunk and that Revigör states "Revigör should not be used to increace alcohol consumption".

It all seems rather well, until Svenska Dagbladet decides to make an article regarding this. They choose "Scientists warns about hangover medicine" as a headline, the original headline was "Hangover medicine is a scam". Thus doing the classic "Scientists warn of X", which is rather popular in the Swedish press. The article mainly focuses on a very poor statement made by Fredrik Spak, one of the scientists. He says "To fool consumers into believing that they can drink any amount of alcohol without the effects of a hangover can in the end lead to addiction", this part, I can't understand. This is not at all what is claimed in the original article, no mention of addiction is made. Either Spak is out of his league and making claims he can not back up or the journlist at SvD has screwed up totally when quoting him (which judging by the rest of the article is not entirely unlikely).

This, however spurred a couple of angry comments by readers and several bloggers have commented on "The evil scientists, who think drinking is bad". All this because of one statement and the fact that SvD switches the focus from the "medicine" being a scam to it being harmful. I have never experienced such a poorly written article. The original article consists to about 80% on debunking the claims of Revigör and about 10% to any possible effects a false medicine might have. Then why does the SvD article consist of the opposite proportions? Also, why does the readers immediately think that the scientists are against them drinking? At no point does any of them say that they shouldn't drink, the only comment is the one of Spark which is totally irrational. I believe that this big mess is partially SvD's fault. Do they have a science part of the paper? Did they even read the first article made by the scientists? I don't have a job for this summer and if SvD needs someone to help them establist some basic understanding on how to write articles about science and even more important, how to keep true to an original article. I am free, and not that expensive.

Now, due to bad journalism the only scientific fact is lost. Revigör makes scientific claims, yet cannot support them. Thus making it a perfect example of pseudoscience. And yet... why is neither the journalists at SvD or the Swedish bloggers upset about being lied to?


Links:
The original article in GP (in Swedish)
The article made on the subject by SvD (in Swedish)
Revigörs homepage (in Swedish)

Wednesday 4 July 2007

SvD and the war terrorism

It has been quite some time since I felt the need to comment on a newspaper article but I can't let a thing like this pass uncriticized. SvD writes today as a part of an article on terrorism (translated from Swedish).

"Yesterday in the papers pop singer Dilba was complaining about how she was treated after making a "joke" about blowing up airplanes at Arlanda airport. She had been treated "like a terrorist" and been told that she was not allowed to board her aircraft to the US. Instead she should be thankful that society is taking terrorism seriously. The anti terrorist measures she is complaining about is working."

Then the article proceeds to other matters. Let me first say, what a load of complete crap! Does anyone believe that following up on every clue no matter how trivial, will make us safer? Terrorists are not likely to go up to security guards and tell them that they are carrying a bomb. Let us look at the two parties in this story. Why does Dilba joke about blowing up airplane? She is clearly sarcastic about it. This is probably since she as a customer is annoyed to be searched and thinks that the whole procedure is ridiculous. She is therefore "complaining" in her own way, although it's is a stupid move. The staff on the other hand are acting all jumpy, they hear the word bomb and goes nuts. They know what they are looking for and better safe than sorry right? But acting like this is not to take the threats seriously. It's to take things out of proportion and go paranoid. The companies clearly don't mind security at all, they only care about looking secure. So that they can point out that in fact they are doing something. Real security would involve calm and reasonable employees who upon Dilbas remark says "Really? Well, cut the crap. What are you really going to do on your stay in the US? Did we check her bag?". We should praise real work to prevent terrorism, not silly security acts. Real terrorists are smarter than Dilba and therefore the security staff should be smarter as well.

Link to the article (in Swedish).
Link to the article about Dilba (in Swedish).

Monday 2 July 2007

Making a Multi column JList

I have a small project going on that involves making a Swing GUI. Swing has all the elements I need, apart from a multi column JList. I did some browsing and found an example that worked. But I thought that it was rather static and decided to make a quick hack which was dynamic and in my opinion easier to understand. It should also be fairly easy to change the code into whatever you want it to render. For example in my project I will make it render even and odd indexes differently.

The license basically says, "Do what ever you want with it, just don't claim that you made it and don't try to endorse your product using my name in case you use it in your product.". I hope someone finds it useful.

HINT: Blogger is not that good at displaying code. Here is a link to a source file containing the code.

/**
* Copyright (c) 2007, Pontus Stenetorp
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of the author nor the names of any contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

import java.awt.*;
import java.util.*;
import javax.swing.*;

/**
* An example using a ListCellRender capable of rendering columns to render
* a Multi-Column JList into a JFrame. The example should be fairly easy to
* follow, if you are mainly interested in how to make a ListCellRenderer and
* how to modify it after your own taste, just skip everything but the
* MultiColumnCellRenderer class.
*
* @author Pontus Stenetorp
* @version 2007-07-02
*/
public class MultiColumnExample extends JFrame {
// See Serialization for more info, this is to remove a warning.
private static final long serialVersionUID = 1L;

private static final int ROWS = 17;
private static final int COLUMNS = 7;
private static final int ELEMENTLENGTH = 7; // The length of the element Strings.
private static final String TITLE = "MultiColumnJListExample";

private ArrayList data;
private JList list;
private MultiColumnCellRenderer cellrenderer;

private MultiColumnExample() {
// Set up the JFrame
super(TITLE);
this.setResizable(false);
this.setBackground(Color.LIGHT_GRAY);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setLocation(800/2 - COLUMNS * ELEMENTLENGTH * 5, 0);

// Create the JList
data = new ArrayList();
this.addExampleData(data);
list = new JList(data.toArray());
cellrenderer = new MultiColumnCellRenderer(COLUMNS);
list.setCellRenderer(cellrenderer);

// Play around with the colours and rendering settings.
list.setSelectionForeground(Color.WHITE);
list.setSelectionBackground(Color.BLACK);
int column = 1;
cellrenderer.setFGColour(column, Color.WHITE);
cellrenderer.setBGColour(column, Color.BLACK);
cellrenderer.setSFGColour(column, Color.BLACK);
cellrenderer.setSBGColour(column, Color.WHITE);

// Add the JList to the JFrame and display it.
this.getContentPane().add(list);
this.pack();
this.setVisible(true);
}

/**
* Adds some example data to a given ArrayList.
* @param arraylist The ArrayList to add data to.
*/
private void addExampleData(ArrayList arraylist) {
Random rand = new Random();
final int MAXVALUE = (int) Math.pow(10,ELEMENTLENGTH);
for(int i = 0; i < ROWS; i++) {
String[] datacolumn = new String[COLUMNS];
for(int j = 0; j < COLUMNS; j++) {
// Let's have a String if it's even.
if(j % 2 == 0) {
// If you don't understand this bit, search the web for ASCIITABLE
char[] tobestring = new char[ELEMENTLENGTH];
for(int u = 0; u < ELEMENTLENGTH; u++) {
tobestring[u] = (char) ('a' + rand.nextInt((int)('z' - 'a')));
}
tobestring[0] -= 'a' - 'A'; // Uppercase the first letter
datacolumn[j] = new String(tobestring);
}
// And some funky integers if odd.
else {
datacolumn[j] = String.valueOf(rand.nextInt(MAXVALUE));
}
}
arraylist.add(datacolumn);
}
}

/**
* A simple example of a ListCellRenderer capable of rendering several columns.
* The ListCellRenderer is also capable of manipulation of the colour of
* specific columns. You can of course add more functionallity with ease just
* by adding say different colours depending whether or not the index is odd
* or even using %. Feel free to use it and play around with it.
*
* @author Pontus Stenetorp
* @version 2007-07-02
*/
private class MultiColumnCellRenderer extends JPanel
implements ListCellRenderer {
// See Serialization for more info, this is to remove a warning.
private static final long serialVersionUID = 1L;

private JLabel[] labels;
private Color[] fgs; // Stores the foreground colours for each column.
private Color[] bgs; // Stores the background colours for each column.
private Color[] sfgs; // Stores the foreground colours for each column when selected.
private Color[] sbgs; // Stores the background colours for each column when selected.

/**
* The JList has to hold objects of type and length String[columns].
* If no Color has been set to a column it will use the default
* colours of the JList.
*
* @param columns The amount of columns that the JList stores.
*/
public MultiColumnCellRenderer(int columns) {
setLayout(new GridLayout(1, columns));
labels = new JLabel[columns];
fgs = new Color[columns];
bgs = new Color[columns];
sfgs = new Color[columns];
sbgs = new Color[columns];

for(int i = 0; i < columns; i++) {
labels[i] = new JLabel();
labels[i].setOpaque(true);
add(labels[i]);
}
}

/**
* @param column The column you wish to set the foreground of.
* @param colour The Color to render the column foreground with.
*/
public void setFGColour(int column, Color colour) {
fgs[column] = colour;
}

/**
* @param column The column you wish to set the background of.
* @param colour The Color to render the column background with.
*/
public void setBGColour(int column, Color colour) {
bgs[column] = colour;
}

/**
* @param column The column you wish to set the selection foreground of.
* @param colour The Color to render the column foreground with.
*/
public void setSFGColour(int column, Color colour) {
sfgs[column] = colour;
}

/**
* @param column The column you wish to set the selection background of.
* @param colour The Color to render the column background with.
*/
public void setSBGColour(int column, Color colour) {
sbgs[column] = colour;
}

public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
// You might want to change this line in case you don't use String[]'s.
String[] celldata = (String[])value;

for(int i = 0; i < celldata.length; i++) {
labels[i].setText(celldata[i]);

// Colour logic, highly configurable.
if(isSelected) {
if(sbgs[i] != null) {
this.labels[i].setBackground(sbgs[i]);
}
else {
this.labels[i].setBackground(list.getSelectionBackground());
}

if(sfgs[i] != null) {
this.labels[i].setForeground(sfgs[i]);
}
else {
this.labels[i].setForeground(list.getSelectionForeground());
}
}
else {
if(bgs[i] != null) {
this.labels[i].setBackground(bgs[i]);
}
else {
this.labels[i].setBackground(list.getBackground());
}

if(fgs[i] != null) {
this.labels[i].setForeground(fgs[i]);
}
else {
this.labels[i].setForeground(list.getForeground());
}
}
}

super.setEnabled(list.isEnabled());
super.setFont(list.getFont());
return this;
}
}

public static void main(String[] args) {
MultiColumnExample mce = new MultiColumnExample();
}
}

Links:
Link to a source file containing the above code.
This was the code that I found and decided to make my own example.
Thanks to Eli Bendersky, without your post I wouldn't have figured out how to post my code.